Web fonts give you typographic control that system fonts cannot match. But they come with a cost: additional HTTP requests, render-blocking behavior, and layout shifts. A poorly loaded font can delay your page’s first contentful paint by seconds or cause text to flash and reflow after the page appears to be ready.

This guide covers how to load fonts efficiently, which strategies to use for different situations, and how to get the typography you want without sacrificing performance.

How Browsers Load Fonts

Understanding the loading sequence helps you make better decisions:

  1. The browser parses HTML and builds the DOM
  2. It parses CSS and discovers @font-face declarations
  3. It determines which fonts are actually needed (based on which text uses them)
  4. It downloads the needed font files
  5. While downloading, the browser must decide what to show: nothing, a fallback font, or wait

Steps 4 and 5 are where performance problems happen. The font file has not arrived yet, but the text is ready to render. What should the browser do?

FOUT, FOIT, and FOFT

These acronyms describe the visual artifacts of font loading:

  • FOIT (Flash of Invisible Text): The browser hides the text until the font loads. This was Chrome’s old default — text was invisible for up to 3 seconds.
  • FOUT (Flash of Unstyled Text): The browser shows text in a fallback font, then swaps to the web font when it loads. This causes a visible reflow.
  • FOFT (Flash of Faux Text): A strategy where you load a minimal version of the font first (e.g., regular weight only), then load additional weights. The initial swap is small, and subsequent swaps are barely noticeable.

None of these are ideal, but FOUT is generally the best user experience — users can read the text immediately, even if the font changes slightly.

The font-display Property

font-display gives you explicit control over what happens during font loading:

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

font-display Values

Value Block Period Swap Period Use Case
auto Browser decides Browser decides Default (usually FOIT)
block 3 seconds Infinite Icon fonts, where invisible text is acceptable
swap ~0ms Infinite Body text — show fallback immediately
fallback ~100ms ~3 seconds Best balance — short block, limited swap
optional ~100ms None Performance-critical — uses font only if cached
  • Body text: Use swap. Users should read content immediately.
  • Headings: Use swap or fallback. A small layout shift in headings is acceptable.
  • Icon fonts: Use block. Invisible icons are better than showing random characters.
  • Performance-critical pages: Use optional. The font loads for the next visit but does not delay the current one.
/* Body font — always show text */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter.woff2') format('woff2');
  font-display: swap;
}

/* Icon font — hide until loaded */
@font-face {
  font-family: 'Icons';
  src: url('/fonts/icons.woff2') format('woff2');
  font-display: block;
}

Preloading Fonts

By default, fonts are not downloaded until the browser discovers that rendered text needs them. This means the font download starts late — after HTML parsing, CSS parsing, and render tree construction.

Preloading tells the browser to start downloading the font immediately:

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

Important Details

  • Always include crossorigin: Font requests use CORS, even for same-origin fonts. Without this attribute, the browser downloads the font twice.
  • Only preload fonts you actually use: Preloading a font that no visible text uses wastes bandwidth.
  • Limit preloads: Preloading too many fonts competes with other critical resources. Preload 1-2 fonts maximum.
  • Use WOFF2: It is the most compressed format and has universal browser support.

When to Preload

Preload fonts that are used above the fold and are critical for the first paint. Do not preload fonts that are only used further down the page — let those load normally.

Font Subsetting

Most font files contain glyphs for many languages and character sets. If your site is English-only, you are downloading thousands of unused glyphs.

Using unicode-range

The unicode-range descriptor tells the browser to only download the font file if the page contains characters in that range:

/* Latin characters only */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}

/* Cyrillic characters */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-cyrillic.woff2') format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
  font-display: swap;
}

Google Fonts does this automatically — it splits fonts into subsets and serves only the ones the page needs.

Creating Subsets Manually

Use tools like pyftsubset (from fonttools) to create subset font files:

# Install fonttools
pip install fonttools brotli

# Create a Latin-only subset
pyftsubset Inter-Regular.ttf \
  --output-file=Inter-Regular-latin.woff2 \
  --flavor=woff2 \
  --layout-features='*' \
  --unicodes="U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F"

This can reduce a 300 KB font file to under 30 KB.

Variable Fonts

Variable fonts contain multiple styles (weights, widths, italic) in a single file. Instead of downloading separate files for Regular, Bold, Italic, and Bold Italic, you download one file that interpolates between any value.

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Variable.woff2') format('woff2-variations');
  font-weight: 100 900;  /* Supports any weight in this range */
  font-display: swap;
}

/* Use any weight value */
h1 { font-weight: 800; }
body { font-weight: 400; }
.light { font-weight: 300; }
.semibold { font-weight: 600; }

Advantages

  • Fewer HTTP requests: One file instead of 4-8 separate font files
  • Smaller total size: One variable font is usually smaller than 3+ static fonts
  • Design flexibility: Use any weight, not just predefined ones (450, 550, etc.)
  • Smooth animations: You can animate between weights

Variable Font Axes

Axis Property Range Example
wght font-weight 100-900 font-weight: 650;
wdth font-stretch 75-125% font-stretch: 110%;
ital font-style 0-1 font-style: italic;
slnt font-style (oblique) -90 to 90 font-style: oblique 12deg;
opsz font-optical-sizing varies font-optical-sizing: auto;

Custom axes (defined by the font designer) are accessed with font-variation-settings:

.text {
  font-variation-settings: 'CASL' 0.5, 'MONO' 1;
}

To preview how different fonts look with your text and explore available options, try our font preview tool.

Self-Hosting vs CDN

Self-Hosting Advantages

  • No third-party requests: Faster on HTTP/2 (same connection as your other assets)
  • Privacy: No data sent to Google or other CDN providers
  • Reliability: No dependency on external services
  • Cache control: You control cache headers and invalidation

CDN Advantages

  • Cross-site caching: If another site loads the same font from the same CDN, it might be cached already (less effective now that browsers partition caches by top-level domain)
  • Global distribution: CDNs serve from edge locations worldwide
  • Automatic optimization: Google Fonts serves optimized subsets and formats

Recommendation

Self-host your fonts. The cross-site caching benefit of CDNs has been eliminated by cache partitioning in modern browsers. Self-hosting gives you better control, fewer third-party dependencies, and typically faster loading on HTTP/2.

Download Google Fonts for self-hosting:

# Use google-webfonts-helper or fontsource
npm install @fontsource/inter

# Or download directly and convert
# Save WOFF2 files to your /fonts directory

Optimizing the Font Stack

Define your font stack with a good fallback that minimizes layout shift:

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

Matching Fallback Metrics

Use CSS @font-face descriptors to adjust the fallback font’s metrics to match your web font, so the swap moves the line less:

@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  ascent-override: 90.49%;
  descent-override: 22.56%;
  line-gap-override: 0%;
  size-adjust: 107.06%;
}

body {
  font-family: 'Inter', 'Inter Fallback', sans-serif;
}

Tools like fontaine and Next.js’s @next/font can calculate these overrides automatically.

Performance Checklist

  1. Use WOFF2 format — best compression, universal support
  2. Set font-display: swap for text fonts, block for icon fonts
  3. Preload critical fonts — 1-2 fonts used above the fold
  4. Subset fonts — only include character sets you need
  5. Use variable fonts when you need 3+ weights or styles
  6. Self-host instead of using a CDN
  7. Limit font families — 2 families maximum for most sites
  8. Match fallback metrics — reduce layout shift with size-adjust and override descriptors
  9. Use font-display: optional for non-critical fonts on performance-sensitive pages

For encoding font files or other binary data as base64 when inlining small fonts in CSS, the Base64 encoder can handle the conversion. Note that inlining fonts as base64 in CSS is generally not recommended for files over a few KB, as it prevents caching the font independently.

Summary

Web font loading is a balance between visual design and performance. Use font-display: swap to show text immediately, preload critical fonts to start downloads early, subset fonts to reduce file sizes, and consider variable fonts when you need multiple weights. Self-hosting gives you the most control and the best performance on modern browsers. The goal is simple: get your chosen typography in front of users as fast as possible, without sacrificing readability during the loading process.