-
Notifications
You must be signed in to change notification settings - Fork 28.3k
Font preload not working as expected #62332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
My workaround for this in my own application is to place this in in layout.tsx. This performs the preload as expected but I have to deal with the mangled font name; which I am hoping is a content hash.
|
I can confirm that this does NOT affect the site as deployed on Vercel - just local next build/next start. |
Hi @jasonthorsness I have the exact same error which I have been debugging for the past few days, without success. All of the attempts have done were all deployed on Vercel and not local. We both import Inter fonts from next/font/google. I did a Vercel build old of 12 days where fonts and markdown are displayed correctly: but it is not the case on the next build that was 3 days ago There is an HTML header difference between the old fonts where it worked, where the header has this:
while the latest one only has this:
I did the following:
Other symptoms: |
TEMPORARY FIX: reverting back to a previous Vercel CLI version To set the Vercel CLI version, add the env variable Now the exact reason on why fonts are not preloaded on |
I can confirm that @vmeylan's suggestion of setting the |
@jasonthorsness @vmeylan Can also confirm this is issue. According to the network tab in Chrome dev tools, the browser only requests fonts once it parses the global stylesheet that contains the Next.js-generated In my case (next@14.1.14, vercel_cli@latest), Next.js seems to include preload My workaround is setting |
I faced the same problem today and am somewhat confident that it's Windows-specific. Because in addition to vercel obviously building on Linux, I also just built the same project using WSL and got the preload links as well. (I'm not using the vercel CLI and wonder whether people having problems with that are actually facing a different problem. Or maybe some transitive dependency is different with different CLI versions that also happens to be different on different OSes? Something native? 🤔) |
Just checked, I import font into |
Has anyone been able to solve this ? Preloading fonts does not work at all. |
Link to the code that reproduces this issue
https://github.com/jasonthorsness/repro001
To Reproduce
npm run build
npm run start
Navigate to localhost:3000 in dev tools in Chrome and observe the absence of a preload for the fonts in the initial HTML response
Current vs. Expected behavior
Expected
Both the Google and Local fonts should have a link rel preload in the first HTML sent back from the server
Actual
Neither font has a preload entry in the first HTML sent back from the server and they aren't downloaded until the CSS references them.
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Font optimization (next/font)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
Here is the content I see in the initial HTML response - note lack of preload for the fonts
The text was updated successfully, but these errors were encountered: