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
| Value | Text hidden for | Web font swapped in | Passes the insight |
|---|---|---|---|
auto | Up to the browser | Up to the browser | No |
block | 2 to 3 seconds | Whenever it arrives | No |
swap | No time at all | Whenever it arrives | Yes |
fallback | About 100 ms | Only if it arrives within about 3 seconds | No |
optional | About 100 ms | Never, unless it was ready within those 100 ms | Yes |
Why fallback no longer passes
The old audit accepted
swap,optionalandfallback, as Chrome's original guide still shows. The insight is stricter: its source code flags any font set toblock,fallbackorauto, and Chrome's Font display docs say onlyswaporoptionalpass. 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
- 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.
- 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.
- 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.
- 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.
- 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.
Load fonts without hiding text or shifting the layout
- Website speedFind what makes your pages slow enough that visitors leave.
- Render-blocking resourcesBring useful content into view sooner by changing how CSS, scripts and fonts load.
- Large layout shiftsRead which elements moved during load and what likely pushed them, then reserve the space they need.
- LCP elementFind which image or text block your LCP measures, then make sure the browser finds and fetches it first.