Skip to main content
InterviewHubPRO
Section Overview
Q40

Question 40 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

80%
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):

  1. font-display: swap: Immediately displays system fallback font while the custom font downloads, ensuring fast First Contentful Paint.
  2. Font Subsetting: Stripping unused glyphs (e.g. Cyrillic, Kanji) reduces .woff2 font sizes from 250KB to 15KB.
  3. size-adjust and ascent-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 */
}