Optimizing Web Font Loading
Web fonts are essential for maintaining visual consistency, but depending on how they are loaded, they can significantly impact page rendering speed. On first visits in particular, text may remain invisible until the font file finishes downloading — a phenomenon known as FOIT (Flash of Invisible Text).
Choosing the Right font-display Value
The CSS font-display property lets you control how text behaves while a font is loading. Setting it to swap shows fallback text immediately and swaps in the web font once it's ready, preventing a degraded user experience. For brand logos or icon fonts where a flash of unstyled text is undesirable, block or optional may be more appropriate. Choosing the right value for each use case is key.
Reducing File Size with Subsetting
CJK fonts contain a large number of glyphs, resulting in hefty file sizes. By extracting only the characters actually used, you can dramatically reduce the payload. Google Fonts handles subset delivery automatically, but if you self-host your fonts, you'll need to subset them manually.