๐Ÿ‹
Menu
Best Practice Beginner 2 min read 326 words

Web Fonts Loading Strategy for Fast Page Rendering

Web fonts can delay text rendering by seconds. Learn the optimal loading strategy to balance visual quality with performance using preload, font-display, and fallback stacks.

Key Takeaways

  • When a page uses a web font, the browser must download the font file before rendering text.
  • ### Preloading Critical Fonts Use `<link rel="preload">` for your most important font files (typically regular weight body text): ```html <link rel="preload" href="/fonts/inter-var.
  • Only preload 1-2 critical font files โ€” preloading everything defeats the purpose.
  • ## The Web Font Problem When a page uses a web font, the browser must download the font file before rendering text.
  • Best for body text โ€” text is always readable.

The Web Font Problem

When a page uses a web font, the browser must download the font file before rendering text. During this download, text is either invisible (FOIT โ€” Flash of Invisible Text) or displayed in a fallback font and then swaps (FOUT โ€” Flash of Unstyled Text). Both degrade user experience.

font-display Values

The font-display CSS descriptor controls browser behavior during font loading:

  • swap: Show fallback immediately, swap to web font when loaded. Best for body text โ€” text is always readable.
  • optional: Show fallback immediately, swap only if font loads very quickly (~100ms). Best for decorative fonts โ€” avoids layout shift on slow connections.
  • fallback: Brief invisible period (100ms), then fallback, then swap within 3 seconds.
  • block: Invisible for up to 3 seconds, then fallback. Only use for icon fonts.

Preloading Critical Fonts

Use for your most important font files (typically regular weight body text):


Preloading starts the download immediately rather than waiting for CSS parsing. Only preload 1-2 critical font files โ€” preloading everything defeats the purpose.

Subset and Optimize

Most web fonts include thousands of characters you'll never use. Subsetting reduces a 200KB font to 20KB by including only the characters your site needs. Use unicode-range in @font-face to load language-specific subsets on demand. Always serve WOFF2 format โ€” it's 30% smaller than WOFF.

The Fallback Stack

Choose fallback fonts that closely match your web font's metrics (x-height, width, weight) to minimize layout shift during swap. Tools like Fontaine and @next/font automatically generate size-adjusted fallback fonts. A good fallback stack: "Inter", "Inter Fallback", system-ui, -apple-system, sans-serif.

Performance Budget

Aim for under 100KB total web font download. Each font weight and style is a separate file โ€” load only what you use. Variable fonts can replace multiple static files with a single file that contains all weights, often reducing total download size.

Alat Terkait

Format Terkait

Panduan Terkait