Yashveer Singh
Connect
<- All posts
Performance Optimization11 min read

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.
CauseFix
Images without dimensionsSet width and height attributes
Iframes that arrive lateAspect ratio container
Web font swapsize-adjust on fallback
Ad or banner injectionReserve space or hide
Layout animationsUse transform instead
Lazy loaded sectionsSkeleton 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

PatternImplementation
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 reserveDisplay the placeholder with dimensions even if banner is loading
Skeleton loaderMatch the exact dimensions of the eventual content
Transform animationtransform: translateY(...) instead of top: ...
Layout shift detectionRun 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

  1. Images without width and height attributes.
  2. Iframes without aspect ratio containers.
  3. Web fonts with default swap behavior.
  4. Banners injected above existing content.
  5. Animations using top or left instead of transform.
  6. Skeleton loaders that do not match the content dimensions.
  7. No CI enforcement of CLS budget.
  8. Measuring CLS only in Lighthouse, not in RUM.

A two week plan to fix CLS

  1. Week one. Audit current CLS across the top pages. Identify causes.
  2. 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.

FAQ

Frequently asked

Author

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.

Related reading