Web Vitals & Performance (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
Font Loading Strategies: `font-display: swap` vs. `optional`.
junior Levelweb-vitalsBasic
In Simple Words:
font-display: swap:- Displays fallback system font immediately while web font downloads. Swaps to the web font once downloaded.
- Risk: Causes visible text reflow and layout shifts (CLS) if glyph widths differ!
font-display: optional(Recommended for Zero CLS):- Gives the custom font an extremely short window (~100ms) to load.
- If it misses the window, the fallback font is used for the entire session. The custom font is cached in the background for the user's next page navigation. Guarantees zero layout shift!