Web Vitals & Performance (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Font Performance Optimization: `font-display: swap` and Size-Adjust.
senior LevelCode ExampleFormsPerformanceSystem Design
In Simple Words: Web fonts cause FOIT (Flash of Invisible Text) or FOUT (Flash of Unstyled Text) and trigger Cumulative Layout Shift (CLS):
font-display: swap: Immediately displays system fallback font while the custom font downloads, ensuring fast First Contentful Paint.- Font Subsetting: Stripping unused glyphs (e.g. Cyrillic, Kanji) reduces
.woff2font sizes from 250KB to 15KB. size-adjustandascent-override: Matches fallback system font dimensions to the web font, eliminating layout shift when the font swaps!
css
@font-face {
font-family: 'FallbackInter';
src: local('Arial');
ascent-override: 90%;
size-adjust: 104%; /* Matches exact line-height to prevent CLS */
}