CLS Without Tears: Layout Stability Patterns
Cumulative Layout Shift measures how much the visible content moves around as the page loads. A good CLS is under 0.1. A poor CLS is over 0.25. The fix is mechanical. Reserve space for images, embeds, and async content. Use font display strategies that do not cause reflow. Avoid injecting content above existing content. The patterns are small. The impact on user trust is large.
Written by Yashveer Singh, founder of Yashveer Labs.
What you actually need to know
- CLS under 0.1 is good. Under 0.05 is excellent.
- Set width and height on every image.
- Reserve space for iframes with aspect-ratio.
- Tune fallback font metrics to match the web font.
- Never inject above existing content after layout.
| Cause | Fix |
|---|---|
| Images without dimensions | Set width and height attributes |
| Iframes that arrive late | Aspect ratio container |
| Web font swap | size-adjust on fallback |
| Ad or banner injection | Reserve space or hide |
| Layout animations | Use transform instead |
| Lazy loaded sections | Skeleton placeholders with right size |
The core argument
Cumulative Layout Shift is the Core Web Vital most users feel directly. The user starts reading. The page shifts. The user loses their place. The user taps something and the page shifts. The user taps the wrong target. The shift creates a felt experience of unreliability that is hard to recover from. Even one significant shift in the loading sequence damages trust.
The fix is mechanical. Most CLS comes from a handful of causes. Images without dimensions. Embeds that arrive after layout. Web fonts that reflow text on swap. Banners injected dynamically. Animations that affect layout properties. Each has a known pattern.
The discipline is to apply the patterns by default. Width and height on every image. Aspect ratio containers around every embed. Font display strategies tuned to match the fallback. No injection above existing content. The patterns add a few lines of code per surface and produce dramatic CLS improvements.
The cost of the discipline is small. The investment per surface is minutes. The return is a page that feels solid under the user's fingers. The Core Web Vitals improvement is a side benefit. The user trust improvement is the main benefit.
The pattern reference
| Pattern | Implementation |
|---|---|
| Image dimensions | <img width="800" height="600" src="..."> |
| Iframe aspect ratio | <div style="aspect-ratio: 16 / 9"><iframe></iframe></div> |
| Font metric override | @font-face { font-family: Inter-fallback; src: local("Arial"); size-adjust: 107%; ascent-override: 90%; } |
| Banner reserve | Display the placeholder with dimensions even if banner is loading |
| Skeleton loader | Match the exact dimensions of the eventual content |
| Transform animation | transform: translateY(...) instead of top: ... |
| Layout shift detection | Run Lighthouse in CI, measure in RUM |
How much does this cost
The investment per page is minutes to a few hours for serious surfaces. The ongoing cost is the discipline to apply the patterns by default. Both are small. The return is a page that feels solid and a CLS score that passes Core Web Vitals.
Features the CLS discipline must have
- A linter rule for missing image dimensions.
- A code review checklist that includes CLS patterns.
- Real User Monitoring with CLS as a tracked metric.
- A budget for CLS that blocks regressions in CI.
- A design system that includes the patterns by default.
- A skeleton component that matches the content it replaces.
Expert opinion
CLS is the cheapest Core Web Vital to fix. The patterns are small and well known. The teams that ignore them ship pages that feel cheap even when they look polished. The teams that apply them ship pages that feel solid. The work per page is minutes. The user impact is real and immediate.
>
Yashveer Singh, founder of Yashveer Labs
How this played out on a real project
A client's marketing site had a CLS of 0.32, well above the failure threshold. The pages looked polished but felt jumpy on mobile. The user research had identified the jumpy feeling as a trust concern without naming CLS specifically.
We audited the pages. Three causes accounted for almost all of the CLS. Hero images without dimensions. A web font swap that reflowed the headline. An above the fold banner injected after layout.
The hero images got width and height attributes. The web font got a fallback with size-adjust tuned to match. The banner got moved below the hero so injection did not push content.
The CLS dropped to 0.04 across the marketing site. The pages stopped feeling jumpy. The Lighthouse score crossed 90. The work took two days of focused frontend time.
For more on the related work, see largest contentful paint the metric that changes conversions and font loading the subtle discipline that improves LCP.
Common mistakes teams make
- Images without width and height attributes.
- Iframes without aspect ratio containers.
- Web fonts with default swap behavior.
- Banners injected above existing content.
- Animations using top or left instead of transform.
- Skeleton loaders that do not match the content dimensions.
- No CI enforcement of CLS budget.
- Measuring CLS only in Lighthouse, not in RUM.
A two week plan to fix CLS
- Week one. Audit current CLS across the top pages. Identify causes.
- Week two. Apply the patterns. Measure the improvement. Add CI enforcement.
For more on the related work, read largest contentful paint the metric that changes conversions and INP the new core web vital most teams are failing. On the broader frontend side, building cinematic web experiences without killing performance is the natural next read.
Frequently asked
Why I am built for this project type
I have worked on five production systems before turning eighteen. That is not a flex. That is a statement of capability. Yashveer Singh, founder of Yashveer Labs. The work in this article is the work I do on a weekly basis. If you are facing the problem I just described, I do not need to be sold on solving it. I need to be told the constraints.
Posts that line up with this one.
- Performance Optimization
Image Optimization at Scale: AVIF, WebP, Responsive Images
Images are the largest contributor to page weight on most web products. Here is the format selection, responsive image, and delivery strategy that cuts load time without manual work.
- Performance Optimization
INP: The New Core Web Vital Most Teams Are Failing
Interaction to Next Paint replaced First Input Delay in 2024 and it is harder to pass. Most teams have not caught up. Here is what INP measures, why it matters, and how to fix the common failure patterns.
- Performance Optimization
Largest Contentful Paint: The Metric That Changes Conversions
LCP is the Core Web Vital that measures how fast the main content loads. It is also the metric most directly correlated with conversion rate. Here is what causes poor LCP and how to fix it systematically.
- Performance Optimization
Lazy Loading: The Patterns That Work and the Ones That Backfire
Lazy loading reduces initial page weight when done correctly. When done incorrectly, it delays the content users actually need and hurts Core Web Vitals. Here is how to apply it with precision.