A good typeface is part of a brand, but it also affects speed. Until the font file arrives, the browser either hides the text or shows it in a fallback font and swaps it later. In the first case visitors stare at a blank page, in the second the text jumps in front of them. Both hurt LCP and CLS, and both can be softened with a few lines of CSS and HTML.
How the browser waits for a font
The browser only requests a font after it has parsed the HTML and CSS and knows which text needs it, so fonts sit late in the loading queue. A font from another domain also needs a DNS lookup plus TCP and TLS handshakes. Meanwhile, the font-display property decides what happens to the text. Without it, most browsers keep text invisible for a short period (up to about 3 seconds), known as FOIT.
Choosing a font-display value
For most sites swap is the right choice: text renders immediately in a fallback and is replaced when the web font arrives. If the brand font is not critical and you want to remove the swap jump entirely, use optional: if the font does not arrive almost immediately, that page keeps the fallback and later pages use the cached font.
| Value | Text behaviour | Good for |
|---|---|---|
block | Hidden briefly, then swapped | Icon fonts |
swap | Fallback at once, swapped later | Most sites |
fallback | Very short hide, limited swap window | Text-heavy blogs |
optional | No swap if the font is late | Speed first |
Self-host your fonts
Google Fonts is convenient, but every visit means connecting to two extra domains, and because browsers partition their cache by site, a font cached elsewhere is not reused on yours. Serving WOFF2 files from your own hosting is often faster since the connection is already open. Make sure unicode-range covers U+0400-04FF, because Uzbek Cyrillic letters such as қ, ғ and ҳ lie outside the basic Cyrillic range.
@font-face {
font-family: "Montserrat";
src: url("/fonts/montserrat-400.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
unicode-range: U+0000-00FF, U+0400-04FF;
}
@font-face {
font-family: "Montserrat";
src: url("/fonts/montserrat-700.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
unicode-range: U+0000-00FF, U+0400-04FF;
}
If you must keep Google Fonts, at least add preconnect hints and display=swap:
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap"
rel="stylesheet">
Preload only what the first screen needs
preload tells the browser to fetch a font before it discovers it in CSS. Use it for one or two fonts visible on the first screen; preloading everything makes fonts compete with images and CSS. The crossorigin attribute is required even on your own domain, otherwise the file is downloaded twice.
<link rel="preload" href="/fonts/montserrat-400.woff2"
as="font" type="font/woff2" crossorigin>
A Samarkand restaurant site: from six weights to two
A restaurant site, misol.uz, loaded two font families in six weights from Google Fonts. On phones the menu text stayed invisible for over a second, then headings grew and pushed buttons down. The design actually used only regular and bold. Keeping one family and two weights, self-hosting them, subsetting to Latin and Cyrillic and preloading the main file cut total font weight several times over, and text appeared immediately. The biggest win came from dropping unnecessary fonts, not from tricks.
Subsetting and variable fonts
Many font files include hundreds of glyphs your site never uses. pyftsubset from fonttools keeps only the characters you need and outputs WOFF2. Check that the font licence allows modification. If you need many weights, a single variable font file is often lighter than several static ones.
pip install fonttools brotli
pyftsubset Montserrat-Regular.ttf \
--unicodes="U+0000-00FF,U+0400-04FF" \
--flavor=woff2 \
--output-file=montserrat-400.woff2
Reducing the swap shift
When fallback and web font metrics differ, line lengths change on swap and text moves. The size-adjust, ascent-override and descent-override descriptors let you tune a local font such as Arial to match. The values below are only a sample; tune them by overlaying both fonts. Then verify in PageSpeed Insights and serve font files with long cache headers.
@font-face {
font-family: "Montserrat Fallback";
src: local("Arial");
size-adjust: 112%;
ascent-override: 85%;
descent-override: 22%;
}
body {
font-family: "Montserrat", "Montserrat Fallback", sans-serif;
}