Font Loading for Core Web Vitals: font-display, Preload and Subsetting
Custom fonts make a website look distinctive, but they are also a common reason text appears late or jumps after loading. Good font loading protects Largest Contentful Paint (LCP), First Contentful Paint (FCP) and Cumulative Layout Shift (CLS), especially on mobile connections. Techniques such as font-display swap, preloading and subsetting keep your brand typography while removing most of the performance cost.
Why Fonts Affect Core Web Vitals
- Invisible text: some browsers hide text until the web font downloads, delaying the moment users can read the page.
- Late discovery: fonts referenced inside CSS are found only after the CSS downloads and is parsed.
- Layout shift: when the web font replaces the fallback font, different letter widths can move text and push content down.
1. Use font-display: swap
The font-display descriptor controls what happens while a font loads. With swap, the browser shows text immediately in a fallback font, then swaps in the web font when ready.
@font-face {
font-family: "Inter";
src: url("/fonts/inter-var.woff2") format("woff2");
font-weight: 100 900;
font-display: swap;
}
If you load Google Fonts, add &display=swap to the stylesheet URL. For decorative fonts that are not essential, optional is worth considering: the browser uses the web font only if it arrives very quickly, which avoids late swaps entirely.
2. Preload the Fonts You Need Above the Fold
Preloading tells the browser to fetch a font early instead of waiting for the CSS:
<link rel="preload" href="/fonts/inter-var.woff2" as="font" type="font/woff2" crossorigin>
Preload only one or two files used in the first screen, usually the main text and heading weights. Preloading every font competes with the hero image and can make LCP worse. The crossorigin attribute is required even for fonts on your own domain.
3. Self-Host and Use WOFF2
Self-hosting removes extra connections to third-party domains and gives you control over caching. Serve WOFF2, which compresses well and is supported by modern browsers, with a long cache lifetime and a versioned file name.
4. Load Fewer Fonts
Each family, weight and style is a separate file. Many sites load six or more files when two would do. Consider:
- One family for text and headings, or a system font for body text.
- A variable font that covers several weights in one file.
- Removing italic and extra weights that appear rarely.
5. Subset Character Sets
Font files often include characters for many languages. Subsetting removes unused glyphs. For bilingual English and Arabic sites, serve separate files with unicode-range so Arabic glyphs load only on pages that use them. Our guide to Arabic SEO for bilingual websites covers wider bilingual considerations.
6. Match Fallback Metrics to Reduce CLS
Modern CSS lets you adjust a fallback font so it occupies nearly the same space as the web font:
@font-face {
font-family: "Inter Fallback";
src: local("Arial");
size-adjust: 107%;
ascent-override: 90%;
}
body { font-family: "Inter", "Inter Fallback", sans-serif; }
The exact percentages depend on the fonts; tools and framework plugins can calculate them. When metrics match, the swap is barely visible and CLS stays low.
How to Test
- Run PageSpeed Insights on key templates and check the LCP element and any font-related warnings.
- In Chrome DevTools, throttle the network and watch the Performance panel for late text rendering and layout shifts.
- Compare field data in Search Console's Core Web Vitals report after deployment.
For the wider picture, see our explainer on Core Web Vitals: INP, LCP and CLS and our guide to responsive images and LCP.
Our web development team builds font loading, image delivery and caching into every Laravel and WordPress project from the start.
Frequently Asked Questions
Is font-display: swap always best?
It is a safe default for text fonts. For non-essential decorative fonts, font-display: optional can avoid late swaps altogether.
Should I use Google Fonts or self-host?
Both can perform well. Self-hosting gives more control over caching, subsetting and preloading, and avoids an extra third-party connection.
How many fonts should a website load?
As few as possible. One or two files for the first screen is a good target, with other weights loaded only where needed.
Comments
Comments appear after admin approval.