Websites
Web fonts and loading time: fast without layout shifts
A beautiful corporate typeface is part of the brand. Embedded without a check, it often weighs more than all the images on a page and makes text jump while loading. A few changes make it light.
In short
- A font reduced to the characters actually used is often only a fifth of the original size.
- font-display and a matching fallback font prevent invisible text and layout shifts.
- With unicode-range, each language loads only the characters it really needs.
What it is about
When examining a website’s loading time, most people look at images first. Yet surprisingly often it is the fonts. A modern variable font with all weights and character sets easily weighs several hundred kilobytes, and it is needed on every page before the text can even appear. In one project, the corporate font was by far the largest file on the home page.
There is a second problem as well: if the font loads late, the browser shows the text in a fallback font first, or not at all. When it then swaps, lines and paragraphs jump. Google measures these layout shifts as Cumulative Layout Shift, and they noticeably disturb readers.
How it works
The biggest lever is subsetting. A font often contains thousands of characters for dozens of languages. An English or German website only needs the Latin alphabet with accents and punctuation. When the font is reduced to that and delivered as WOFF2, it typically shrinks to a fifth. The original file stays archived in the project, together with the licence, which for open fonts usually explicitly allows such modification.
The second lever is loading behaviour. font-display defines what happens while the font is missing. The value optional only uses the corporate font if it arrives very quickly; otherwise the fallback remains for that visit, without a later swap. To keep the difference barely noticeable, a fallback font with adjusted metrics is defined. For further languages, unicode-range ensures that Cyrillic or Arabic character sets, for example, are only loaded when such characters actually appear on the page.
Where it goes wrong
A typical mistake is invisible demand. In a multilingual project, even German pages suddenly loaded the Cyrillic and the Arabic font. The cause was a collapsed language menu: the language names in their original scripts were invisible, but the browser still laid them out. Only when the closed menu was really taken out of the layout did the extra weight disappear.
A second mistake is fonts from third-party servers. They cost extra connections, fall under data protection and have to be allowed in the Content Security Policy. Self-hosted fonts are faster and easier to secure.
How to proceed
List all font files your pages actually load, with their size. Reduce each font to the character sets you need and deliver it as WOFF2 from your own server. Choose font-display deliberately and define a metric-compatible fallback font. Load other writing systems only via unicode-range. And after every design change, check again which fonts are really loaded, because new elements often bring new characters unnoticed.
Read more: Images and load time: fast websites despite large photos, Measuring PageSpeed properly: lab data, field data, fluctuations and Building a multilingual website: addresses, translation, text direction.
How Airnite helps
We analyse which fonts your website loads, reduce them to what is necessary and ensure a calm page build without layout shifts. Your look stays the same, while your loading time and your values in Google improve.
Checklist
Sources
Every fact in this article is based on the following publications. Primary sources are marked.
- web.dev (Google)Best practices for fonts
- MDN Web Docsfont-display
- MDN Web Docsunicode-range
Matching services
Read on
Images and load time: fast websites despite large photos
The hero photo is 6 megabytes because that is what the camera delivered. On a phone with a poor signal, the customer waits until they give up. It does not have to be that way.Websites3 minMeasuring PageSpeed properly: lab data, field data, fluctuations
The PageSpeed Insights score is often read like a school report. But it is only a snapshot under lab conditions. Anyone who wants to improve must know what is being measured and what is not.SEO3 minBuilding a multilingual website: addresses, translation, text direction
Translating a website is more than copying text into another field. Addresses, form of address, technical terms, fonts and, for Arabic, even the reading direction must be planned from the start.Current incidents and warnings are covered in the Zero Day magazine. Go to the magazine