Keep your text on screen while web fonts download

Ensure text remains visible during webfont load was the Lighthouse audit for web fonts that can leave text invisible while they download. Lighthouse 13 replaced it with the Font display insight, which passes when each web font uses font-display: swap or optional. With the default setting, Chromium browsers and Firefox hide text set in a font that hasn't arrived for up to 3 seconds.

What each font-display value does

ValueText hidden forWeb font swapped inPasses the insight
autoUp to the browserUp to the browserNo
block2 to 3 secondsWhenever it arrivesNo
swapNo time at allWhenever it arrivesYes
fallbackAbout 100 msOnly if it arrives within about 3 secondsNo
optionalAbout 100 msNever, unless it was ready within those 100 msYes

Why fallback no longer passes

  • The old audit accepted swap, optional and fallback, as Chrome's original guide still shows. The insight is stricter: its source code flags any font set to block, fallback or auto, and Chrome's Font display docs say only swap or optional pass. A page that passed the old audit can fail the insight without any change to its CSS.

  • Each flagged font comes with a Wasted time figure, based on how long the font file took to download and capped at 3 seconds. It's the insight's estimate of how long text in that font stayed hidden. The block and swap periods in the table above come from web.dev's font best practices.

How to keep text visible while fonts load

  1. List the fonts the insight flagsRun Lighthouse or PageSpeed Insights and open the Font display insight. Note each font file it lists and which stylesheet declares it.
  2. Add font-display to each font faceIn every @font-face rule you control, add font-display: swap for brand and heading fonts, or optional for body text where a late font shouldn't replace the fallback.
  3. Add the display parameter for Google FontsYou can't edit the @font-face rules Google Fonts serves, so add display=swap or display=optional to the end of the stylesheet's URL, as Chrome's original guide for the audit shows.
  4. Replace icon fonts with SVGA fallback font shows ordinary characters where the icons should be, and they can mean something else entirely. web.dev recommends SVG icons instead, which also helps accessibility.
  5. Watch for layout shift after the changeWith swap, text can move when the web font replaces the fallback. Match the fallback's size with size-adjust in its @font-face rule, or preload the one or two fonts the first screen uses.

Frequently asked questions

Why does the insight flag fonts I didn't add?

Fonts that a theme, plugin or embedded widget loads into the page count too. If their CSS sets no font-display, or one the insight rejects, the font appears in the list. Change the setting where the theme or plugin offers one, or host the font yourself so you control its @font-face rule.

Does font-display affect Largest Contentful Paint?

It can when the largest element on screen is text. web.dev's LCP guide notes that with a font-display value other than auto or block, the text stays visible during load, so LCP doesn't wait for the font file to download.

Do system fonts need font-display?

No. The font-display descriptor belongs in an @font-face rule and controls how a downloaded font is shown. A stack of fonts already installed on the device has nothing to download, so text set in them never waits.