Engineering Guides
Production @font-face CSS: Preload, crossorigin, and font-display Strategy
Write bulletproof @font-face CSS with font-display: swap vs optional, crossorigin preload hints, and metric-matched fallbacks for fast LCP.
Quick Answer
For fast production web fonts, serve WOFF2 exclusively with font-display: swap (paired with size-adjust fallback metrics) or optional, preload only the 1–2 primary above-the-fold weights using <link rel="preload" as="font" type="font/woff2" crossorigin>, and remove legacy EOT, TTF, and SVG URLs to prevent redundant browser downloads.
Choosing between font-display: swap, fallback, and optional
Leaving font-display unset triggers FOIT (Flash of Invisible Text) for up to 3 seconds in most browsers, hurting First Contentful Paint. Choosing font-display: swap shows text immediately with the fallback font and upgrades once WOFF2 lands; choosing optional gives the font a ~100 ms swap window and otherwise sticks to fallback until the next navigation, ensuring zero late shifts.
| Value | Block Period | Swap Period | Best Use Case |
|---|---|---|---|
| swap | ~0–100 ms | Infinite | Brand headings & body paired with CLS overrides |
| optional | ~100 ms | None | Strict zero-CLS body copy on variable networks |
| fallback | ~100 ms | ~3 seconds | Balanced fallback on flaky connections |
Open tool:Generate @font-face + preload CSS →
The crossorigin preload rule everyone forgets
Because font requests are always fetched in anonymous CORS mode per the CSS Fonts spec, a <link rel="preload" as="font"> tag missing crossorigin initiates a non-CORS fetch that cannot match @font-face—causing browsers to download the font twice!
Always include crossorigin even when the .woff2 sits on your own domain, and restrict preloads strictly to the 1–2 weights rendered above the fold.
<link
rel="preload"
href="/fonts/inter-regular.woff2"
as="font"
type="font/woff2"
crossorigin
/>Pairing @font-face with Anti-CLS overrides
FontTo inspects your font's actual weight class, italic flag, variable axes, and OS/2 vs hhea metrics to emit copy-paste @font-face CSS, preload HTML, and Anti-CLS fallback rules together.
Open tool:Pair CSS with size-adjust overrides →
Frequently asked questions
How many fonts should I preload on a page?
Preload at most 1–2 above-the-fold weights (e.g. Regular 400 and Bold 700). Preloading 6+ fonts competes with hero images and critical CSS.
Should I include local() in @font-face src?
Generally avoid local() for web fonts because user-installed versions of fonts like Inter or Roboto may be outdated or lack localized glyphs.
Do I still need WOFF, TTF, and EOT lines inside src:?
No. Modern browsers since 2016–2018 support WOFF2, so keeping only format('woff2') keeps CSS lean and maintainable.
Authoritative References
Tools used in this guide
Related formats
Related Comparisons
More engineering guides
- Self-Hosting Google Fonts for GDPR Compliance & Zero Third-Party RequestsEliminate external fonts.googleapis.com requests for European GDPR compliance by packing local WOFF2 fonts, @font-face CSS, and CLS fallbacks.
- Zero Layout Shift Web Fonts: Calculating size-adjust & ascent-overrideEliminate Cumulative Layout Shift (CLS) on web font swap using exact OS/2 vs hhea formulas for size-adjust, ascent-override, and descent-override.
- Base64 Inline WOFF2 vs. External Font Files: When Data URIs Make SenseWeigh Base64 Data URI fonts (+33% overhead and CSSOM blocking) against external WOFF2 files—and learn when inline subsetting actually wins.