Cumulative Layout Shift (CLS)
You'll learn how SSR prevents unexpected content jumps by delivering fully-formed HTML from the server.
What is CLS?
Cumulative Layout Shift measures visual stability—how much content unexpectedly moves around while a page loads. Imagine reading an article when suddenly an image loads above your paragraph, pushing everything down. You lose your place, or worse, click the wrong button. CLS quantifies these frustrating shifts with a score (lower is better, ideally under 0.1).
The Client-Side Rendering Problem
With pure CSR, the browser receives minimal HTML—often just a <div id="root"></div>. JavaScript must download, parse, execute, fetch data, and then render content. During this process, elements appear in stages:
- Blank screen
- Layout skeleton
- Text renders (layout shifts as fonts load)
- Images pop in (more shifts)
- Ads or dynamic content insert (even more shifts)
Each stage can cause visible jumps, accumulating a high CLS score.
How SSR Prevents Layout Shifts
Server-Side Rendering delivers complete markup on the initial response. The server already knows:
- Exact dimensions of images (width/height attributes rendered)
- Final text content (no waiting for API calls)
- Styled components with critical CSS
- Reserved space for dynamic elements
When the HTML arrives, browsers can calculate layout immediately. Content appears in its final position from the start—no surprises, no shifts. Think of it like receiving a finished puzzle versus watching pieces appear randomly one by one.
The server has already done the work of fetching data and rendering the full component tree, so the browser paints a stable, complete page on first load.
Key Takeaway: SSR dramatically reduces CLS by delivering fully-rendered markup with known dimensions upfront, eliminating the progressive layout changes that plague client-only rendering.