CLS (Cumulative Layout Shift)
CLS (Cumulative Layout Shift) is a Core Web Vitals metric that measures how much the content of a page unexpectedly moves while it loads. A high CLS score creates a poor user experience and can hurt your Google rankings.
What is CLS?
Cumulative Layout Shift (CLS) measures the visual stability of your web page. It records how much visible content unexpectedly changes position while the page loads. If you have ever tried to click a button that suddenly moved because an image or an ad loaded above it, you have experienced a layout shift.
CLS is one of Google's three Core Web Vitals and is used as a ranking factor in search results.
How is CLS measured?
CLS is calculated as the sum of all individual layout shifts that happen without user interaction:
- Good: CLS below 0.1, with minimal or no visible movement
- Needs improvement: CLS between 0.1 and 0.25
- Poor: CLS above 0.25, with significant unexpected movement
Only layout shifts that happen without user interaction (scrolling, clicking) count. If a user clicks a button and the content changes, that is expected and does not count.
Common causes of CLS in online stores
- Images without dimensions: If images do not have width/height attributes in the HTML, the browser does not reserve space for them, and the content below the image jumps when the image loads.
- Dynamic content: Banners, ads, or product recommendations that load after the initial rendering of the page and push content down.
- Web fonts: Fonts that load late and have a different size than the fallback font (FOUT, Flash of Unstyled Text) can move content.
- Cookie/consent banners: Cookie consent bars that appear after the page has loaded and push the content down.
- Lazy-loaded content: Elements that are lazy-loaded without space reserved for them.
How to improve CLS
- Set dimensions on images: Always specify width and height on all
<img>elements, so the browser can reserve space before the image loads. - Reserve space for dynamic content: Use CSS (min-height or aspect-ratio) to reserve space for banners, ads, and other elements that load dynamically.
- Use font-display: swap; This prevents invisible text but can cause FOUT. Combine it with preload for the best balance.
- Place cookie banners as an overlay: Use position:fixed, so they do not push the page content.
- Preload important resources: Use <link rel="preload"> for critical fonts, images, and CSS.
CLS and Shoporama
Shoporama's themes are designed with performance in mind. To get the best CLS score, make sure that all product images have the correct dimensions and that external content (chatbots, tracking scripts) loads without affecting the layout.
Measuring tools
- Google PageSpeed Insights: Shows CLS for both mobile and desktop, including the specific elements that contribute to layout shifts.
- Chrome DevTools (Lighthouse): Run a Lighthouse audit to see CLS and the other Core Web Vitals.
- Google Search Console: The Core Web Vitals report shows CLS performance for your entire site based on real user data (CrUX).
- Web Vitals Chrome Extension: Shows CLS and the other Core Web Vitals in real time while you browse.
How to do it in Shoporama
Guides that show the term in practice
Optimize images for mobile with responsive images
A guide to using responsive images with srcset in your Shoporama theme, so mobile users get optimized images.
Image quality and image format in Shoporama: WebP, JPG, and PNG
Learn how Shoporama handles image quality and image formats, and what you can do if your images don't look sharp enough.
We know online marketing at Shoporama
We have worked with online marketing ourselves for decades. As the only e-commerce platform in Denmark, we have spoken several times at conferences such as Marketingcamp, SEOday, Shopcamp, Digital Marketing, E-commerce manageren, Ehandelsdagen, Web Analytics Wednesday, and many more.