Web fonts: fast text rendering without layout shifts
If headings on your website disappear for a moment, text suddenly „jumps“ into a different typeface after loading, or a button moves under a visitor’s finger, web fonts are often the cause. The fix is usually not to give up your brand typeface, but to load fewer files, let the browser discover them earlier, choose a suitable font-display strategy and match the dimensions of the fallback font.
This article gives you a practical procedure for a company website or online store: from an inventory of font styles, through WOFF2 and character subsets, to deciding whether to self-host Google Fonts. Every step can be verified in the browser’s developer tools.
How fonts slow down a website and why text jumps
According to the Best practices for fonts guide on web.dev, web fonts affect performance in two ways. Until a font has loaded, the browser typically delays text rendering, which can delay First Contentful Paint and sometimes Largest Contentful Paint. The second problem is layout shift (CLS): if the fallback font and the web font take up different amounts of space, swapping the font moves the content.
The same source states that Chromium-based browsers and Firefox block text rendering for up to 3 seconds by default if the font has not loaded yet, and Safari blocks it indefinitely. You can change this behaviour with the font-display descriptor, which MDN marks as widely available across browsers since January 2020.
Example: a company website with two font families
Illustrative example: a company runs a WordPress website with a brand typeface for headings and a second typeface for body text. The theme loads both families from Google Fonts via @import in an external stylesheet, six styles in total, plus an icon font for arrows and social media icons. On a slower mobile connection the main heading appears late, and after the font swap the intro paragraph and the contact button both shift.
An audit in the Network tab of the developer tools shows which font files are actually downloaded and when. In a case like this it usually helps to reduce the number of styles, replace the icon font with SVG icons, move the font declarations into the document head and choose a strategy for body text that does not cause shifts. The actual benefit must be measured before and after the change, not estimated.
Step-by-step procedure
1. Inventory: which font styles you really use
List the families, weights and styles that are actually displayed on the website. Web.dev points out that an @font-face declaration by itself does not trigger a download; the font is only downloaded when styling used by an element on the page references it. Unnecessary styles therefore often come from the theme, a page builder or a plugin, not from the content.
2. Fewer files: system font or variable font
The fastest font is one that is never downloaded. A system font (font-family: system-ui) may be enough for body text. A variable font replaces several styles with a single file, but web.dev adds that it is usually larger than an individual style; it pays off mainly when you really use many weights and styles.
3. WOFF2 and a character subset for Central European languages
Use the WOFF2 format. According to web.dev it has the widest support and, thanks to Brotli compression, is about 30% smaller than WOFF. If you host fonts yourself, create a character subset and set unicode-range so that only the characters you need are downloaded.
For Slovak, Czech, Hungarian or Polish, basic Latin is not enough. Characters such as č, ť, ő or ł belong to Latin Extended, so the subset must include them, otherwise letters with diacritics are displayed in the fallback font. Before modifying files, check that the font licence allows subsetting and self-hosting.
4. Choose a font-display strategy
The value block hides text for a short time, swap shows the fallback font almost immediately and swaps in the web font whenever it arrives, fallback allows the swap only for a short period, and optional does not allow a swap at all after the short block. Web.dev recommends optional when performance and no font-swap shifts are the priority, and swap when the web font must always be shown; in that case, however, it has to be delivered early enough. The strategies can be combined: swap for brand headings and optional for body text.
5. Let the browser discover the font earlier
According to web.dev, @font-face declarations and critical styles belong in a <style> block in the head rather than in an external file. For third-party fonts add preconnect; for Google Fonts, one for the stylesheets and a separate one with the crossorigin attribute for the font files. According to the same source, loading via <link> is likely faster than @import.
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
Use preload sparingly: it takes resources away from other downloads, ignores unicode-range and should load only one format. It makes sense mainly for one or two of the most important styles that the browser would otherwise only discover from an external stylesheet.
6. Match the dimensions of the fallback font
If you use swap, a fallback font with adjusted metrics reduces the shift. According to MDN, the size-adjust descriptor scales all font metrics by the given percentage, and it has been widely available since September 2023. The web.dev article on size-adjust also describes fine-tuning with ascent-override, descent-override and line-gap-override.
@font-face {
font-family: "Brand-fallback";
src: local("Arial");
size-adjust: 97%; /* illustrative value, must be measured */
}
h1, h2 { font-family: "Brand", "Brand-fallback", sans-serif; }
Set the value by comparing both fonts on the same text, not by guessing. Web.dev also warns that a local font such as Arial may not be available on every device, so list several fallback families.
Self-hosting or Google Fonts?
Self-hosting removes the connection to another server, but it is not automatically faster. Web.dev mentions the Web Almanac finding that sites using third-party fonts rendered faster, and recommends self-hosting mainly when you use a CDN and HTTP/2. When you switch, you have to provide the WOFF2 files and subsets yourself, which the provider otherwise does automatically.
The second reason is privacy: when a font is downloaded from someone else’s server, the visitor’s browser connects to it and passes on the technical request data, including the IP address. Since version 6.5, WordPress includes the Font Library; according to the developers‘ announcement, installing a font from the Google Fonts collection downloads the file to the WordPress server, by default into the wp-content/fonts folder.
The same announcement states that installed fonts must be re-activated after switching themes, and that the library can be used to deactivate unneeded theme fonts. Local files do not help, however, if the theme or a plugin still inserts a link to an external font, so verify the result in the Network tab. The legal assessment of data processing is up to the website operator and their adviser.
Decision table
| Situation | Recommended approach | What to watch out for |
|---|---|---|
| Regular article and product text | System font or font-display: optional |
On a slow connection the fallback font may be shown. |
| Brand headings and logo set in text | swap with an adjusted fallback font |
Without size-adjust a visible shift is likely. |
| Google Fonts via an external stylesheet | <link> and preconnect, or self-hosting |
Self-host only with WOFF2, a subset and a CDN. |
| Icon font | Replace with SVG icons | The icon fallback font conveys a different meaning and shifts the layout. |
| Many weights of one family | Variable font | With only two styles it may be larger than separate files. |
Tradeoffs and common mistakes
Every strategy sacrifices something: optional protects speed and stability, but the brand font may not appear on the first visit; swap shows text quickly, but without matched metrics the page may jump. Common mistakes worth avoiding:
- loading the same font twice, once from the theme and once from a plugin,
- a subset with basic Latin only, without Slovak or Hungarian diacritics,
preloadfor every style instead of one or two critical ones,- moving to local fonts without a CDN, WOFF2 and measurement before and after the change,
- an icon font for navigation that shows meaningless characters when it fails.
Pre-deployment checklist
- We have a list of the families, weights and styles actually used.
- All files are in WOFF2 and the subset contains the characters of every language on the site.
- Every
@font-facehas a deliberatefont-displaysetting. - Font declarations are in the head and external origins have
preconnect. - The fallback font has adjusted metrics and several families are listed.
- No unexpected external font is downloaded in the Network tab.
- The font licence allows self-hosting and subsetting.
- We compared the result with measurements before and after the change.
Frequently asked questions
Is font-display: swap always the best choice?
No. It shows text fastest, but a late swap can cause a shift. For body text optional is often more suitable, while swap fits brand elements with an adjusted fallback font.
Will my website be faster if I download Google Fonts to my own server?
Not necessarily. Web.dev points out that the difference is not clear-cut and recommends self-hosting mainly with a CDN and HTTP/2. Measure the transfer time, including connection setup, before and after the change.
How many font styles are reasonable?
There is no universal number. What matters is what the design really uses. Each style is a separate file, so keep only those with a clear role on the page.
How do I find out whether fonts cause layout shifts?
Throttle the network in the developer tools, watch the first render and the font swap, and check layout shifts in the Performance panel. If the content moves at the moment the font is swapped, optional or matched metrics will help.
Help with website speed and typography
We optimise fonts as part of website and online store development and maintenance: we check which fonts are downloaded, propose changes without losing your visual identity and verify the result with measurements. If you would like your website reviewed, get in touch. You will find more practical guides on our blog.