question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

font-display:swap fonts shouldn't affect lantern lcp

See original GitHub issue

I’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:

grafik

After adding the suggested preloading lines for my fonts the LCP increased a lot and the performance rating goes down to 80 %:

grafik

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:open
  • Created 3 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
patrickhulcecommented, Feb 7, 2021

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.

1reaction
patrickhulcecommented, Sep 19, 2020

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

ci:
  collect:
    settings:
      throttlingMethod: devtools

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found