Practice ยท 1 of 3
CLS Calculator
Layout shifts arrive as an array of { fraction (0..1 of viewport that moved), distance (fraction of viewport it moved) }; each shift's impact = fraction * distance; shifts within 500ms of the previous count into the same session (gap in ms given per shift as sincePrev). CLS = the LARGEST session total. Write cls(shifts).
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Vitals & Budgets โ Practice