Web font loading: avoiding blank text and layout jumps
Review font loading, display behavior and layout shifts when custom web fonts delay text or make a page jump.
Custom fonts can make a page look better and, if loaded carelessly, delay text. web.dev's guide (https://web.dev/articles/optimize-webfont-loading) explains why and what to do.
Why text can go blank
web.dev says the browser has to build the render tree before it knows which font files it needs, so font requests start well after other critical resources, and the browser may be blocked from rendering text until the font arrives. The race between first paint and the font request is what creates the "blank text problem", where the layout appears without text. Splitting a font family into subsets and styles with @font-face lets browsers download only what is needed, which web.dev calls convenient, but it can also create a bottleneck.
Three fixes web.dev describes
- Preload fonts you know the page needs. A preload hint starts the request early without waiting for the CSS object model. web.dev says this makes availability more likely but offers no guarantees.
- Choose font-display. This CSS property sets how the browser behaves while the font is unavailable, through a block period, a swap period and a failure period. Values: auto, block, swap, fallback, optional. The article explains the periods; we do not pick a value for you, since the right one depends on whether your brand needs the exact font on first view.
- Cache fonts well. web.dev says fonts are static and suited to a long max-age with an ETag and a Cache-Control policy, and that with a service worker a cache-first strategy suits most cases. It advises against storing fonts in localStorage or IndexedDB and says the browser's HTTP cache is the best mechanism.
Link to Core Web Vitals
The article discusses preloading and font-display as controls for font loading. Their effects depend on the selected policy and timing: showing fallback text promptly does not itself guarantee a layout-shift-free font swap. We link that to CLS in the explainer on Core Web Vitals, but this guide does not provide measurements.
Checklist for your developer
- Which font files and weights do we really need?
- Are the critical ones preloaded?
- Is font-display set deliberately?
- Do font files carry long-lived cache headers and revalidation tokens?
- Did we re-test the page in Lighthouse after changes?
The checklist is ours, based on the guide.
Limits
We did not read the Font Loading API section in detail and make no speed claims.
By Omnistu.