Performance · Frontend · CSS · Core Web Vitals

Web Font Performance: font-display, Preload and Subsetting

Keep custom fonts from slowing your site: WOFF2, font-display, preload, subsetting, variable fonts and fallback metrics that prevent layout shift.

Sander Yazıcıoğlu Published: 2 min read Türkçe oku

Web Font Performance: font-display, Preload and Subsetting

On this site headings use Exo 2 and code blocks use IBM Plex Mono. Good for brand feel, but every badly loaded font either hides text (FOIT) or makes the page jump when it arrives (CLS). Fonts were one of the things I spent the most time on while moving the Lighthouse score from the 90s to 100.

1. Use WOFF2 only

Every modern browser supports WOFF2. Keeping TTF, EOT or WOFF fallbacks in @font-face only bloats the CSS.

@font-face {
  font-family: 'Exo 2';
  src: url('/fonts/exo2-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+011E-011F, U+0130-0131, U+015E-015F;
}

2. Choosing font-display

ValueBehaviourWhen
swapFallback first, then the custom fontHeadings and body text
optionalSkip the font if it doesn't arrive quicklyWhere performance beats design
blockHides text brieflyIcon fonts (better: don't use them)

For body text, optional is the safest choice for LCP and CLS: first visits get the system font, later visits get the cached custom font.

3. Preload the critical font

Preload the one font used above the fold, not all of them:

<link rel="preload" href="/fonts/exo2-latin.woff2" as="font" type="font/woff2" crossorigin />

crossorigin is required even on the same origin; forget it and the font downloads twice. Preloading four weights steals bandwidth from the LCP image.

4. Subset your fonts

A Google Fonts file contains thousands of glyphs. A Turkish and English site needs only Latin plus a slice of Latin Extended. With pyftsubset:

pyftsubset Exo2.ttf --unicodes="U+0000-00FF,U+011E-011F,U+0130-0131,U+015E-015F" \
  --flavor=woff2 --output-file=exo2-latin.woff2

If you support a language with extra letters, test them. On Turkish sites the classic bug is ğ, ı and ş rendering in the fallback font.

5. Variable fonts

A single variable font (font-weight: 400 800) is usually smaller than four separate weight files and arrives in one request.

6. Kill CLS with fallback metrics

If line lengths change when the custom font arrives, the page jumps. Make the fallback's metrics match:

@font-face {
  font-family: 'Exo 2 Fallback';
  src: local('Arial');
  size-adjust: 104%;
  ascent-override: 92%;
  descent-override: 24%;
}
body { font-family: 'Exo 2', 'Exo 2 Fallback', system-ui, sans-serif; }

Tools such as Next.js next/font and Fontaine calculate these values for you.

7. Self-host

A third-party font CDN adds DNS, TLS and connection cost, and browsers no longer share caches across sites. Serve fonts from your own domain with hashed file names and long-lived caching.

Checklist

  • WOFF2 only, subset
  • Above-the-fold font preloaded, with crossorigin
  • font-display: swap or optional
  • Fallback metrics tuned
  • Self-hosted with an immutable cache

For the same ideas applied to images, see web image optimization; for the bigger picture, the Core Web Vitals guide.

Angular Performance with OnPush and Change Detection

December 2, 2026 · 2 min read

Angular Performance with OnPush and Change Detection

Default versus OnPush change detection in Angular, what triggers an OnPush check, speeding up large lists with track and trackBy, and the most common mistakes.

AngularPerformanceFrontendTypeScript

All articles →