Site AI Auditby Internet Solutions

How to Fix Cumulative Layout Shift (CLS) on Your Website

4 Ogos 20267 min bacaanKelajuan laman web
How to Fix Cumulative Layout Shift (CLS) on Your Website

Short answer: To fix Cumulative Layout Shift, give every image, video, ad slot and embed a reserved size before it loads, never insert banners or notices above existing content, and make web fonts swap in without changing the text size much. A CLS score of 0.1 or less at the 75th percentile of visits is considered good. Most layout shift on small-business sites comes from images without dimensions, late cookie or promo bars and third-party embeds.

Layout shift is the most irritating speed problem for visitors, even though it is not strictly about speed. You start reading and the text jumps down. You try to tap “Add to cart” and hit an ad instead. Visitors rarely complain about it; they just trust the page a little less and sometimes leave. Cumulative Layout Shift (CLS) is the Core Web Vital that measures this, and fortunately it is often the easiest one to fix.

What CLS measures

CLS adds up unexpected movements of visible content during the life of a page. Each shift gets a score based on two things: how much of the viewport was affected (impact fraction) and how far the content moved relative to the viewport (distance fraction). Shifts are grouped into short windows, and CLS reports the worst window, so one bad burst of shifting is enough to fail.

Only unexpected shifts count. If content moves within half a second after the user taps or clicks, for example when an accordion opens, that is treated as expected and ignored. Animations that use CSS transforms do not count either, because they do not move other elements in the layout.

How to find what is shifting

CLS can be tricky because the movement often happens in a fraction of a second on a fast connection, and you never see it on your own computer. Use tools to catch it:

  1. PageSpeed Insights lists “Avoid large layout shifts” in the diagnostics and names the elements that moved and how much each contributed.
  2. Chrome DevTools has a “Layout Shift Regions” option under Rendering that briefly highlights every shift in blue as you load the page.
  3. Throttle your connection. In DevTools, choose a slow network and a slower CPU. Shifts that are invisible at full speed become obvious.
  4. Scroll the whole page. Lab tools only measure the initial load, but real users scroll. Content that loads while scrolling, such as lazy images without dimensions or infinite-scroll lists, adds to field CLS.
  5. Compare with field data. If Search Console reports poor CLS but lab tests look fine, the shift probably happens after load, during scrolling or with a cookie consent choice.

Cause 1: Images and videos without dimensions

This is the classic cause. If an image has no width and height, the browser does not know how much space to reserve, so it lays out the text first and pushes it down when the image arrives.

Cause 2: Ads, embeds and iframes

Third-party content is often the biggest source of layout shift because its size is decided by someone else’s server at the last moment.

Cause 3: Banners, notices and injected content

Cookie banners, promotion bars, “free shipping” notices and newsletter boxes are frequently added by JavaScript after the page has rendered. If they are inserted at the top in the normal document flow, the whole page moves down.

Cause 4: Web fonts

When a web font replaces the fallback font, the size of the text can change. Lines get longer or shorter, paragraphs wrap differently and everything below them moves.

Cause 5: Animations and late CSS

Animating properties such as top, height or margin moves other elements and can count as layout shift. Animate transform and opacity instead. Also check for CSS that arrives late, for example styles loaded by a plugin script, which can change the layout after the first render. Critical layout styles should be available when the page first paints.

Quick reference: causes and fixes

CauseHow it showsFix
Images without sizeText jumps when pictures loadWidth and height attributes, aspect-ratio
Ads and embedsBlocks grow or collapse after loadReserved minimum height
Injected bannersWhole page moves downOverlay or server-rendered bar
Web fontsParagraphs rewrapPreload, font-display, metric overrides
Layout animationsNeighbouring elements moveAnimate transform and opacity

A layout-stability checklist for new pages

Most layout shift is introduced when someone adds a new section, widget or campaign banner. A short checklist during publishing prevents it from coming back:

  1. Every new image and video has width and height, or sits in a container with a fixed aspect ratio.
  2. Every embed (video, map, booking form, reviews, social post) has reserved space before its script runs.
  3. Promotions and notices are part of the page template or appear as overlays, not injected at the top.
  4. New fonts are limited to one or two weights, preloaded if they are used above the fold.
  5. The page has been loaded on a phone with a slow network profile and scrolled from top to bottom.
  6. A lab test after publishing shows CLS well under 0.1.

Agencies and in-house teams can add this list to their definition of done for landing pages. It takes a few minutes per page and saves a month of waiting for field data to recover after a careless release.

How Site AI Audit helps

Every Site AI Audit check includes Google PageSpeed for mobile, with CLS reported next to LCP, INP, server response time and page weight. If layout shift is a problem, the report explains in plain words why it matters and how to fix it, and ranks it against your other findings so you can see whether it deserves attention before, say, an expiring SSL certificate. Paid plans let you re-check after every fix to confirm the score improved.

Related reading

The bottom line

Layout shift happens when the browser does not know how much space something needs. Tell it in advance: set image and video dimensions, reserve space for ads and embeds, show banners as overlays and keep font swaps small. Test on a throttled phone connection and scroll the whole page, because that is where real visitors meet the shifts.

FAQ

What is a good CLS score?

A CLS of 0.1 or less is good, 0.1 to 0.25 needs improvement and above 0.25 is poor. Google evaluates it at the 75th percentile of real visits. Aim to be well below 0.1 so normal variation does not push you over.

Why is my CLS good in lab tests but poor in Search Console?

Lab tests only measure the initial page load without user interaction. Real visitors scroll, accept cookie banners and trigger lazy-loaded content, which can cause shifts later. Scroll through the page with a throttled connection to reproduce what users see.

Do cookie banners cause layout shift?

They do if they are inserted at the top of the page in the normal flow and push content down. Banners that appear as a fixed overlay, usually at the bottom of the screen, do not cause layout shift. Check your consent tool’s display settings.

Does lazy loading cause CLS?

Lazy loading itself does not, but lazy-loaded images without width and height attributes do. When they load during scrolling, the content around them moves. Always set dimensions or an aspect ratio on lazy images.

Do animations count as layout shift?

Animations that change position or size properties such as top, left, width or margin can cause layout shift. Animations using CSS transform and opacity do not, because they do not affect the layout of other elements. Prefer transforms for any motion.

#Core Web Vitals#Mobile performance#Page speed
Semak laman web anda sendiri — percuma.Apa yang perlu dibaiki pada laman web anda — dan dari mana hendak bermula.
Mula percuma

Lagi dari blog

Semua artikel →
Internet Solutions

Lagi daripada pasukan kami

Dibina oleh Internet Solutions. Cuba produk kami yang lain — setiap satu menjimatkan masa anda dengan cara berbeza.

internet-solutions.net ↗
Site AI Audit
Gambaran Keseluruhan Privasi

Laman web ini menggunakan kuki supaya kami dapat memberikan pengalaman pengguna yang terbaik. Maklumat kuki disimpan dalam pelayar anda dan menjalankan fungsi seperti mengenali anda apabila anda kembali ke laman web kami serta membantu pasukan kami memahami bahagian laman web yang paling menarik dan berguna bagi anda.