Preload Fonts Without FOIT
You'll learn how to eliminate the dreaded "flash of invisible text" by combining font preloading with smart display strategies.
What is FOIT?
FOIT (Flash of Invisible Text) happens when browsers hide text while waiting for custom web fonts to download. Your users see blank spaces where headlines and paragraphs should be — not a great experience.
Think of it like a restaurant holding your table but refusing to seat you until a specific chair arrives. You're there, ready to eat, but stuck waiting invisibly.
The Solution: Preload + font-display
By preloading critical fonts and pairing them with font-display, you take control of the rendering timeline:
<!-- In your <head> -->
<link rel="preload"
href="/fonts/my-font.woff2"
as="font"
type="font/woff2"
crossorigin>
/* In your CSS */
@font-face {
font-family: 'MyFont';
src: url('/fonts/my-font.woff2') format('woff2');
font-display: swap; /* Show fallback text immediately */
}
Why This Works
- Preload tells the browser "fetch this font ASAP" before CSS parsing even discovers it
- font-display: swap instructs the browser to show fallback text immediately instead of hiding it
- When your font loads, the swap happens smoothly
The crossorigin attribute is essential even for same-origin fonts — font requests are always CORS-enabled.
Common font-display Values
swap– Show fallback immediately (best for body text)optional– Use font only if already cached (aggressive performance)fallback– Brief invisible period, then swap (balance)
Key Takeaway: Preloading fonts with <link rel="preload" as="font"> combined with font-display: swap ensures text renders immediately with system fonts while your custom fonts load in the background, eliminating FOIT entirely.