Preloading Web Fonts
You'll learn how to use <link rel="preload"> to tell the browser to fetch critical font files sooner, improving perceived performance.
The Problem with Default Font Loading
By default, browsers only discover font files after parsing your CSS and seeing @font-face rules. This delayed discovery means fonts arrive late, causing text to flash or remain invisible longer than necessary. It's like waiting for the chef to read the recipe before ordering ingredients—inefficient!
What Preloading Does
The <link rel="preload"> hint in your HTML <head> tells the browser: "Hey, you'll definitely need this font file soon—start downloading it now, even before you parse the CSS." This early fetch reduces the time users wait to see properly styled text.
How to Preload a Font
Place this in your <head> before your stylesheet link:
<link rel="preload"
href="/fonts/myfont.woff2"
as="font"
type="font/woff2"
crossorigin>
Key attributes:
as="font"— identifies the resource typetype="font/woff2"— specifies format (helps browser decide if it supports it)crossorigin— required even for same-origin fonts (font fetching uses CORS mode)
When to Use It
Only preload fonts that appear above the fold and are truly critical—typically 1-2 files. Preloading everything defeats the purpose and can actually harm performance by delaying other important resources.
Key Takeaway: Preloading critical web fonts with <link rel="preload"> prioritizes their download, reducing the time users see fallback fonts and improving the perceived loading experience.