font-display:swap fonts shouldn't affect lantern lcp
See original GitHub issueI’m a bit confused about the recommendation uses-rel-preload
and the resulting LCP
score. Without font preloading the LCP
score looks ok and results in a 100 % rating in the performance category:
After adding the suggested preloading lines for my fonts the LCP
increased a lot and the performance rating goes down to 80 %:
The preloading lines I use looks like this:
<link rel="preload" as="font" href="/fonts/Metropolis.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="preload" as="font" href="/fonts/LiberationSans.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="preload" as="font" href="/fonts/LiberationSans-Bold.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="preload" as="font" href="/fonts/LiberationSans-BoldItalic.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="preload" as="font" href="/fonts/LiberationSans-Italic.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="preload" as="font" href="/fonts/LiberationMono.woff2" type="font/woff2" crossorigin="anonymous">
<link rel="preload" as="font" href="/fonts/DroidSans.woff2" type="font/woff2" crossorigin="anonymous">
What am I doing wrong? Any way to get preloading and the LCP
together? Thanks a lot for your help.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
font-display - CSS: Cascading Style Sheets - MDN Web Docs
The font-display descriptor determines how a font face is displayed based on whether and when it is downloaded and ready to use.
Read more >Google Fonts is Adding font-display - CSS-Tricks
Google announced at I/O that their font service will now support the font-display property which resolves a number of web performance issues ...
Read more >Controlling Font Performance with font-display
The font swap period occurs immediately after the font block period. During this period, if the font face is not loaded, any element...
Read more >Best practices for fonts - web.dev
Best practices for fonts · Delayed text rendering: If a web font has not loaded, browsers typically delay text rendering. In many situations, ......
Read more >A font-display setting for slow connections
“What font-display setting should be used to improve the ... That's not to mention TTF and OTF fonts which also had varying browser...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, changes to lantern like this requires are large investments and are only shipped with major versions. There is no immediate plan to tackle this.
You’re all good you actually filed in LHCI @xoxys but I moved the issue to the core repo because any issue computing the performance metrics won’t be LHCI specific 😃
I can repro locally now thanks for the download link 👍
This is a bug in simulated throttling. Basically the preloaded fonts now load before LCP and Lighthouse includes them in our pessimistic estimate of LCP. It only happens on localhost because they load so fast that Chrome doesn’t even have a chance to get a paint out. When the page is hosted somewhere remotely we see the expected behavior.
As a temporary workaround you can use
but either way it’s not a real problem with the performance of the page.
To the Lighthouse team, I think it’s time to finally include more than just trace/devtools information in our lantern graph creation. These fonts are all display
swap
and we shouldn’t be including them in the LCP calculation.