DEV Community

BM lm
BM lm

Posted on

Web fonts are a performance bug you shipped on purpose

A 280KB woff2 that renders 60 characters is a 99% waste ratio. Here is the short checklist for shipping web fonts without the performance tax.

Subset, then subset again

Latin-only subsets cut a font by half before you do anything clever. Then cut to the glyphs your content actually uses - a landing page rarely needs the Bulgarian Cyrillic range. pyftsubset from fonttools is one command.

Preload the primary, lazy the rest

One rel=preload for the headline font, font-display: swap for everything else. Users see content immediately; the swap is a flicker, not a blocker.

Watch the layout shift

font-display: swap trades a flash of fallback for a layout shift when the real font lands. size-adjust and ascent-override on the fallback font shrink the jump to near zero - set the fallback metrics to match the real font.

The identification side-quest

Performance work means auditing what actually loads - and audits catch fonts nobody remembers licensing or installing. When the audit finds a mystery webfont and nobody knows what it is, an on-device identifier like Typeye names it from a screenshot in seconds, without uploading client pages to a third party.

The audit, in order

  1. List every font request in DevTools (filter: Font).
  2. Kill duplicates and unused weights - most sites ship 4 weights and use 2.
  3. Subset what remains.
  4. Preload the headline font, swap the rest.

Ship less font. The planet and your Lighthouse score both appreciate it.

Top comments (0)