Preload with font-display Strategies
What you'll learn: How to combine font preloading with font-display values to create the fastest, most user-friendly font loading experience possible.
The Power of Combining Two Techniques
You've learned about preloading fonts (using <link rel="preload">) and controlling how browsers handle font rendering (using font-display). Now it's time to combine them for maximum impact.
Think of preloading as getting your fonts in line early at the airport, while font-display is your backup plan for what happens if the flight is delayed. Together, they cover both the best-case and worst-case scenarios.
How They Work Together
When you preload a font, you're telling the browser to fetch it immediately, before it would naturally discover it in your CSS. This reduces the time to first render with your custom font.
But networks are unpredictable. Even with preloading, a slow connection might delay the font. That's where font-display saves the day—it tells the browser what to do during that wait.
Best practice pattern:
<link rel="preload"
href="primary-font.woff2"
as="font"
type="font/woff2"
crossorigin>
@font-face {
font-family: 'Primary';
src: url('primary-font.woff2') format('woff2');
font-display: swap; /* Fallback strategy */
}
Here, preload accelerates the font download, while font-display: swap ensures text remains visible even if the font takes longer than expected.
Choosing Your Strategy
- Preload +
swap: Fast load, always visible text (most common) - Preload +
optional: Fast load, but font might not appear if preload fails (for non-critical fonts) - Preload +
fallback: Middle ground with brief invisible period
Key Takeaway: Combining <link rel="preload"> with font-display gives you both speed optimization and a safety net, ensuring users see content quickly regardless of network conditions.