Sign inTry Now

What does 'Poor Cumulative Layout Shift (CLS) Score' mean in Site Audit?

Poor Cumulative Layout Shift (CLS) Score

Description

The page has a poor Cumulative Layout Shift (CLS) score, indicating unstable layout elements.

How to Fix

Always include size attributes on images and video elements, reserve space for ads, banners, and iframes, avoid inserting new content above existing content, and prefer transform animations over animations that trigger layout changes.

Detailed Analysis

1. What Causes Poor Cumulative Layout Shift (CLS)?

Cumulative Layout Shift (CLS) measures the visual stability of a webpage. It quantifies how much visible content shifts in the viewport as the page loads. A poor CLS score indicates that elements on the page are moving unexpectedly, which can be caused by:

  • Images without Dimensions: When images don't have specified width and height attributes, browsers may not know how much space to allocate, leading to layout shifts when the images load.

  • Ads, Embeds, and Iframes without Dimensions: Similar to images, if these elements load without predetermined space, they can cause shifts as they load.

  • Dynamically Injected Content: Content that gets added to the page after initial load, such as banners or pop-ups, can push other content around unexpectedly.

  • Web Fonts Causing FOUT/FOIT: Flash of Unstyled Text (FOUT) or Flash of Invisible Text (FOIT) can happen when web fonts load, causing text to shift as the browser replaces fallback fonts with the final font.

  • Actions Waiting for Network Response: If user interactions, such as clicking a button, wait for a network response to update the UI, it can cause unexpected shifts.

2. Why It's Important

  • User Experience: A stable layout improves user experience by making the page more predictable. Unexpected shifts can lead to users clicking on the wrong elements, such as ads or links, which can be frustrating and lead to increased bounce rates.

  • SEO and Rankings: CLS is part of Google's Core Web Vitals, which are used to rank pages. A poor CLS score can negatively impact search rankings, reducing visibility and traffic.

  • Conversion Rates: A stable layout ensures that users can interact with content as intended, potentially improving conversion rates as users can complete tasks without disruption.

3. Best Practices to Prevent Poor CLS

  • Specify Dimensions for Media: Always define width and height for images, videos, and other media. This helps browsers allocate the correct amount of space during the initial load.

  • Reserve Space for Ads: Allocate fixed sizes for ad slots and use CSS to ensure space is reserved, even if ads load asynchronously.

  • Include Font Loading Strategies: Use font-display: swap; in CSS to prevent FOIT and minimize FOUT, ensuring text remains visible and does not cause layout shifts.

  • Avoid Layout Shifts from Dynamic Content: Use placeholders or reserve space for dynamic content such as banners and pop-ups to appear without shifting existing content.

  • Optimize Resource Prioritization: Ensure critical resources load first by optimizing your CSS and JavaScript, and using techniques like preload and async/defer for scripts.

4. Examples of Good and Bad Cases

Bad Case:

  • A news website where images load without defined dimensions, causing text to shift as images appear.
  • An e-commerce site where product details shift due to dynamic loading of sale banners, leading users to accidentally click on incorrect links.

Good Case:

  • A blog page with all images and ads having fixed dimensions, ensuring the text remains stable as other content loads.
  • An online store that uses CSS to allocate space for all dynamic elements, ensuring buttons and links remain in their expected positions even as content updates.

In summary, ensuring a good CLS score involves thoughtful design and coding practices that prioritize user experience by maintaining visual stability throughout the page load process.