Skip to content
Back to blog
5 min read

Web fonts on WordPress: self-hosted WOFF2, variable fonts and no layout shift

Wooden letters scattered on an orange surface

Short answer: load web fonts from your own domain, in WOFF2, with only the weights and character sets the site uses. A variable font replaces several static files when you use three or more weights. Preload the one or two files used above the fold, use font-display: swap or optional, and give the fallback font matching proportions so text does not jump when the web font arrives. Self-hosting also avoids sending visitors’ IP addresses to Google, which a German court found unlawful in 2022.

Why fonts matter for speed

Headings and hero text are often the largest element on the screen, so the font that renders them affects Largest Contentful Paint. When the web font arrives late and has different proportions from the fallback, lines rewrap and the page shifts, which counts against Cumulative Layout Shift. And every extra weight is another file to download. A site with two families, four weights each and italics can easily load a dozen font files; most sites need three or four.

Formats: use WOFF2

FormatUse it?Why
WOFF2Yes, as the only formatBrotli compression, the smallest files, supported by every current browser
WOFFNo, unless you support very old browsersLarger files, no benefit today
TTF or OTFNo, on the webUncompressed desktop formats, several times larger
Embedded OpenType and SVG fontsNoObsolete

Variable or static fonts

A variable font holds a whole range of weights, and sometimes widths or slants, in one file. It pays off when the design uses three or more weights of the same family, because one variable file is usually smaller than three static ones and removes extra requests. For a site that uses only regular and bold, two static files can be smaller. Compare the actual file sizes after subsetting, and keep italics as a separate file only if the design uses them.

Subset to the characters you need

Full font files carry Cyrillic, Greek, Vietnamese and symbols most sites never show. Subsetting keeps only the characters you need. Be careful with European languages: Romanian needs ș and ț with a comma below, German needs ß and umlauts, Polish and Czech need their own marks. These sit in the Latin Extended range, so a Latin-only subset shows them in the fallback font. Use unicode-range so the browser downloads the extended subset only on pages that contain those characters.

Loading: preload, font-display and fallbacks

  • Preload only the file used for the main heading or body text above the fold, with the crossorigin attribute; preloading every weight delays everything else.
  • font-display: swap shows the fallback immediately and swaps when the web font arrives. optional uses the web font only if it arrives very early, which removes the swap entirely on slow connections.
  • Matched fallbacks: size-adjust, ascent-override and descent-override on the fallback font make a system font take the same space as the web font, so the swap causes no layout shift.
  • Cache headers: font files should be cached for a year, and served from your own domain or CDN.

Google Fonts and GDPR

Loading fonts from Google’s servers sends each visitor’s IP address to Google. In January 2022 the Munich Regional Court held that doing this without consent breached GDPR and awarded the visitor 100 euros in damages, which was followed by a wave of warning letters to German site owners. Hosting the same fonts on your own domain removes the issue and is usually faster, since the browser does not have to connect to another domain first.

Fonts in Breakdance

Breakdance lets you add custom fonts in its settings, so we upload the subsetted WOFF2 files there and use them in the global typography settings. Its Google Fonts option loads from Google, so on sites for EU visitors we switch it off and use self-hosted files instead; a caching plugin such as FlyingPress can also download and self-host Google Fonts automatically, which we cover in WordPress caching plugins. After the change we search the page source for fonts.googleapis.com and fonts.gstatic.com to make sure no plugin still loads them.

A checklist for your fonts

  1. List the families, weights and styles the design really uses.
  2. Download them as WOFF2, variable where three or more weights are used.
  3. Subset to Latin plus the extended characters your languages need.
  4. Host them on your domain and remove every request to Google’s font servers.
  5. Preload the one or two files used above the fold.
  6. Set font-display and a matched fallback.
  7. Check Largest Contentful Paint and layout shift with real visitor data; see Core Web Vitals for WordPress.

Fonts are one of the causes covered in why your WordPress site is slow. We set up typography and performance on our WordPress website service. If you want your site’s fonts checked, get in touch.

Frequently asked questions

What is the best font format for websites?

WOFF2. It has the best compression and is supported by every current browser. Other formats are only needed for very old browsers.

Are variable fonts faster?

When a site uses three or more weights of the same family, one variable file is usually smaller than several static files and saves requests. With only two weights, static files can be smaller, so compare the actual sizes.

Should I preload web fonts?

Preload only the one or two files used for text above the fold, with the crossorigin attribute. Preloading every weight competes with more important resources.

Is using Google Fonts GDPR compliant?

Loading fonts from Google’s servers sends visitors’ IP addresses to Google. A Munich court found this unlawful without consent in 2022. Self-hosting the fonts avoids the issue.

How do I stop fonts causing layout shift?

Use a fallback font adjusted with size-adjust and ascent and descent overrides so it takes the same space as the web font, and set font-display to swap or optional.

Share this article