Web Vitals & Performance (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is Cumulative Layout Shift (CLS) and how is it calculated?
junior Levelweb-vitalsBasic
In Simple Words: CLS measures the unexpected movement of visible elements during page loading. If a user is about to click "Cancel", and an un-dimensioned advertisement suddenly pops in, shifting the page down and causing them to click "Confirm Order", that is a catastrophic layout shift.
$$\text{Layout Shift Score} = \text{Impact Fraction} \times \text{Distance Fraction}$$
- Impact Fraction: Percentage of the viewport occupied by unstable elements in both the before and after frames.
- Distance Fraction: Greatest distance the unstable element moved relative to the viewport height.
CLS Thresholds:
- Good: $\le 0.1$.
- Needs Improvement: $0.1 - 0.25$.
- Poor: $> 0.25$.