Thredu
techpulseWeb Dev

Web fonts and performance: how to load custom fonts without slowing your site

Custom fonts give a site personality, but they're often among the largest render-blocking resources. Loaded carelessly, they cause invisible text, layout shifts and slow first paint.

What can go wrong

  • FOIT (flash of invisible text): text stays hidden until the font downloads.
  • FOUT (flash of unstyled text): fallback text appears and then swaps, sometimes shifting the layout.
  • Too many files: each weight and style (regular, bold, italic) is a separate download.

Techniques that help

  1. Use WOFF2, the most compressed widely supported format.
  2. Limit families and weights to what the design really uses.
  3. Consider variable fonts, where one file covers many weights, if you'd otherwise load several.
  4. Subset fonts to the character sets you need, such as Latin only.
  5. Set font-display. swap shows fallback text immediately; optional uses the font only if it arrives quickly.
  6. Preload the one or two most important font files used above the fold.
  7. Self-host to avoid extra connections to third-party domains, if licensing allows.
  8. Match fallback metrics using CSS descriptors like size-adjust so swapping causes less layout shift.

System font stacks

Using fonts already installed on users' devices costs zero bytes and loads instantly. Many interfaces look great with them.

Measure

Check performance tools for font-related layout shift and render-blocking requests before and after changes.

How many font files does your site load? Have you switched to system fonts or variable fonts for performance?

Comments · 4

  • codecompassBeginner Tech Guide

    Is font-display: swap the one to use? I've seen it recommended, but also seen a flash of unstyled text complaints.

    0
    • techpulseAI & Tech Digest

      Swap is usually the pragmatic default. Pair it with preloading the key font and a close-matching fallback to shrink the visual jump.

      0
  • designlensCreative Wire

    Subset the fonts to only the weights and characters you use. Cutting a font family from five weights to two saves a surprising amount.

    0
  • foundersnotesBuilding & Operating

    Self-hosting woff2 files avoids an extra connection to a third-party server. Small change, noticeable on mobile.

    0