Cumulative Layout Shift explained: How to Fix Your Score (r)

Jan 6, 2023
SOmeone in front of a monitor learning about cumulative layout shift

Are you having trouble in a battle with Cumulative Layout Shift issues with your site? Are you confused about the definition of Cumulative Layout Shift really means?

Cumulative Layout Shift, or CLS in its simplest form, is a metric which is part of the Google's Core Web Vitals initiative.

In simple terms, it can be described as a measurement of the frequency with which information on a site changes "unexpectedly". If you have a high CLS score can indicate an unsatisfactory user experience. It could even impact your website's SEO.

In this post this article, you'll discover everything you need to know about Cumulative Layout Shift, and how it affects WordPress websites (and any website in general).

What exactly is Cumulative Layout Shift (CLS)? What is the explanation behind Cumulative Layout Shift Meaning

In order to understand the Cumulative Layout Shift means It is important to understand the notion of shifts in layouts generally.

Layout shifts occur whenever information on your site "moves" or "shifts" in a sudden manner.

If you're trying to describe it into the technical term, it's when an object that is visible in the viewer changes its starting location over two frames.

One example of this could be that you're in middle of reading a block of text...but the late loading advertisement is suddenly displayed and starts showing your text on the screen.
    Here's another example from Google which illustrates the situation:

An example of Cumulative Layout shift from Google.
A good illustration of Cumulative Layout changes derived from Google.

It is likely that you have seen layout changes when surfing on the internet however you might not recognize them as such.

A single visit could have many separate layout shift events. This Cumulative Layout Shift measurement aims to show the entire picture by measuring the entire amount of layout changes that are unexpected in a single document.

The exact measure could be slightly better than the original measurement due to some adjustments made by Google But that's not the fundamental idea. If you're seeking details about the measurement, find out more here.

How can Cumulative Layout Changes be Bad?

It's at best discomforting for guests. Worse, it may cause visitors to do things they do not want to take part in.

For example, imagine if a user wants to click "Cancel" but instead chooses to click "Confirm" because a layout shift moved between the buttons while the person was pressing.

In essence, addressing the Cumulative layout shift issues on your website can enhance your website's user-friendliness for humans and search engines.

What could be causing Cumulative Layout Shift? We'll look into that in the future...

What triggers a change in the design of the layer that is cumulative?

This is a brief overview of the top causes for changing layouts:

  • Do not set dimensions for videos, images Iframes, videos or other embedded content.
  • The dynamic injection of content via plug-ins (cookie consent notices, lead generation forms, and more. ).
  • Making animations with no CSS Transform property.

This post will explore these issues more in-depth later on in this blog post, in which we'll show you the best way to solve each problem.

What is Cumulative Layout Changes The Most Effective Test Tools

There are many applications you could use to determine your website's CLS Score.

These are the top Cumulative Layout Shift tests tools that stand out for their usefulness...

PageSpeed Insights

PageSpeed Insights is one of the most efficient tools for assessing the state of your website's layout changes since it offers two information sources:

  • Field dataactual data about users derived from data in the Chrome UX report (assuming the site is able to attract enough visitors to be included within the reports). This lets you get the exact Cumulative Layout Shift information of your visitors. It is also the data Google makes use of to determine its ranking signals.
  • Lab Data are test results simulated which is acquired via Lighthouse (which is the data PageSpeed Insights uses to generate reports for analyzing the performance).

In addition, you are able to access your information from two devices, mobile and desktop through switching tabs.

Cumulative Layout Shift scores in PageSpeed Insights.
Scores for Cumulative Layout Shift in PageSpeed Analysis.

Be awarethat the information from the lab is only able to measure layout shifts that occur during the page load and your actual results might differ depending on the changes to layout that happen after the load of your page.

Chrome Developer Tools

First, perform the Lighthouse audit and check the site's CLS score. Here's how:

  1. Open Chrome Developer Tools.
  2. Click on the Lighthouse tab.
  3. Create your test.
  4. Click the Analyze load of the page button to conduct the test.

After a short wait after which you should be able to access the normal Lighthouse Audit interface (which appears a lot similar to the PageSpeed Insights).

How to run a Lighthouse audit in Developer Tools.
What can you do to do the Lighthouse audit with Developer Tools.

However, Chrome Developer Tools also allows you to explore CLS through rendering analysis. You can highlight specific layout regions that shift on your website. This helps in identifying the issue.

Here's how:

  1. Select the "three dots" icon in the top-right section on the Chrome Developer Tools interface.
  2. Select Other Toolsand select Rendering and it will open completely new screens toward the bottom.
  3. Look in the box to find the regions of Layout Shift.
How to view CLS rendering in Developer Tools.
How do I view CLS renderings in Developer Tools.

Reload the webpage you wish to test, and Chrome will highlight regions with layout changes using a blue box. Highlights will appear in the actual page as the content is loading but will disappear once the change is finished.

If highlights happen too fast for you to keep track of them, reduce the speed of your site and then watch the site load frame-by-frame with the Performance tab.

Google Search Console

Although Google Search Console cannot allow test labs to identify Cumulative Layout Shiftissues, it does give the user the ability to quickly identify issues with Cumulative Layout Shift in your sitein line to Chrome UX. Chrome UX Report.

Here's how you can spot potential issues on your site:

  1. Get started with the Web Vitals Core Web Vitals report. It is located under the section Experience.
  2. Simply click Open Report on the right side of your Mobile or desktop according to what you're looking to study.
The Core Web Vitals report in Search Console.
The Core Web Vitals report in Search Console.
How to see URLs with CLS problems in Search Console.
Find URLs with CLS problems within Search Console.

NoteYou'll receive information only if your website has enough daily traffic to be able to get in the Chrome UX report.

Layout Change GIF Generator

Its name suggests the fact that this Layout Change GIF Generator generates an GIF that displays the design changes on your website, so you can see exactly what web pages are creating issues. The tool will also provide your score, though this isn't the primary goal of this tool.

Add the URL you want to test and then select either desktop or mobile. The program will create your GIF of your site highlighted in green to show precisely what is shifting.

Once you know what components change and contribute to the score of Cumulative Layout Shift You will know exactly what you need to do to improve your site's score.

The tool highlights individual layout shifts in green.
The tool will highlight the individual design shifts and changes in green.

What is a great cumulative Layout Score?

As per the Google's Core Web Vitals initiative, the optimal Cumulative Layout Shift Score is 0.1 and less.

If your Cumulative Layout Change Score falls between 0.1 and 0.25, Google defines that as "Needs improvements".

If you're Cumulative Layout Shift score exceeds 0.25, Google defines that as "Poor".

Below is an image directly from the Google Core Web Vitals website that displays these scores visually:

Google's recommendations for CLS scores.
Google's recommendations on CLS scores.

What could I do to correct this issue? Cumulative Layout Shift in WordPress (or any other platform)

Once you've figured out the root causes behind Cumulative Layout Shift, it's time to look at some specific suggestions on how you can fix Cumulative Layout Shift in WordPress.

While these suggestions are from the WordPress perspective, all one is general, so you are able to adapt them to other site-building tools.

Always mention what Dimensions of Images

To avoid this issue, you should specify the dimensions of the image within the code in your embed code. Thus, the browser of the user will reserve that space even when it's not loaded thus it will not need to relocate the content.

Are you interested in knowing how we can increase our number of visitors by 1000?

Join over 20,000 others to subscribe to our newsletter, which contains the insider WordPress tips!

The HTML code to embed a basic embedding image appears like this:

An example image

For defining its dimensions, include height in addition to its width parameters. Here is an example of the way that might appear for a 600x300px image:

An example image

width="600" height="300">

Make sure to specify the dimensions of videos and iframes. Don't forget to provide the dimensions for other Embeds

As with images as well, you need to specify dimensions whenever you're making use of iframes, videos, or any other kind of embed.

A majority of embed-related software used on web pages can automatically determine the dimensions of the embed.

An example of iframe dimensions in the embed code.
Iframe Dimensions: An example within embedded code.

It is the same with many other goods and services.

But, if the embed code doesn't specify the height and width you can manually add these dimensions to your embed code.

Correct and optimize Font Loading

problems with font loading or optimization is a frequent cause of shifts in layout through two potential issues:

  • Flash of invisible texts (FOIT)- The site loads first without any text appearing at all. Once the font is been loaded, it appears as though the text has come to life (which can cause existing information to change).
  • Flash that displays text unstyled (FOUT) - the text content loads using an unstyled font that is used across the entire system (unstyled). If the font you've selected is loaded, it switches the font size to that you choose and can cause the content to shift due to the font's dimensions and spacing could differ.

In order to avoid such issues, it is essential to improve the speed at which you upload fonts to your website (which may also have beneficial effects on speed of your site).

Host Fonts Locally, and preload Fonts

If you store fonts locally and preload the fonts, you tell the browsers to provide preference to fonts that are custom.

By loading font files ahead of other resources, you'll be able to be sure that font files will be loaded before the browser begins rendering your website. This could prevent problems related to FOIT and FOUT.

Additionally, you can preload Fonts in a manual manner by adding this code on your head part of your website.

Here's an example code. You must replace the code with the real place of the font's name. the font you'd like to preload.

Make Font-Display Optional or Swap

CSS Font Display Property CSS FontDisplay property allows you to control the behavior of fonts that you display on your site. Additionally, it lets you stay clear of FOIT.

In essence, it lets you make use of a fallback font for situations where the font you've created isn't loading at the moment.

Two primary options that you could use to deal with CLS:

  • Swap Serves as a fallback font while the custom font is loaded . However, it changes to the custom font after the font is loaded.
  • Optionalis an option that lets the browser determine the use of the font of your choice depending on the speed of the visitor.

If you're using Swap it's possible that the browser will continually switch to the customized font when it is loaded.

Although Swap offers a comprehensive solution for FOIT, it could cause FOUT. In order to minimize the risk be sure that the font you use as a fallback has exactly the same spacing as your custom font (at at the very least likely). So, even in the event that font style is changed, the layout won't change because the spacing will remain exactly the same.

If you select the option to enable it. the browser will offer the custom font 100 ms to load. However, if the requested font isn't in the system by that point, the browser will just use the default font, and will not alter it to the custom font for that web page ( it will use the font that it has made for subsequent page visits since it's more probable that the font was saved and downloaded by that point).

While it is possible to use an alternative that is a solution to both FOIT and FOUT, it is a disadvantage that visitors may end up in the default typeface the very first time.

If you're at ease using CSS it is possible to alter the font-display property by hand within the stylesheet of the child theme.

If you're uncomfortable making that decision, look for plug-ins that can aid:

The Elementor Font Display options.
It is possible to use the Elementor Font Display choices.

To complex? Consider an System The System The Stack!

The whole discussion of preloading and font-display can be somewhat confusing, an quick solution is to make use of an existing font stack in place of a custom font stack.

Although this will limit your design options It will solve Cumulative Problems with Layout Shift Fonts FOIT, FOIT, and FOUT. In addition, it will help your site load much faster.

If you're interested by this info, have an interest in Brian's blog post about the best way to utilize a system font stack on WordPress.

Make a place for advertisements (if using Display Ads)

If you're using display advertisements is essential to make space inside your site's code. It's the same principle of reserving space to images, videos, and embeds.

But, they do require attention because they are very typical to display slow-loading ads when making use of any kind of bidding system. This is because the bidding system requires the period of time to contemplate and determine which ads to present.

Mediavine Optimize Ads for CLS setting.
Mediavine Optimizes Ads to CLS setting.

For optimizing AdSense to optimize AdSense for Cumulative Layout Change is a little more complicated.

The most common method is to include a div> wrapper element on top of each advertisement unit which defines a minimum height using the min-heightCSS property. Additionally, you can utilize media queries to modify the minimum height according to the gadget used by the user.

Google recommends that you set the min-height equal to the largest possible ad size. This could result in an inefficient space where a less ad will be being displayed, it's a great way to avoid the risk of layout changes occurring.

Here's how the CSS might look as follows:

Some example CSS for an ad wrapper.
Some example CSS to wrap an advertisement.

Then, here's how the AdSense embed might look like:

Wrap the AdSense ad code in a div.
The AdSense advertisement code in the form of an div.

On the frontend, you'll be able to observe that the website has an advertisement space although it's not:

Your site will now reserve space for that ad on the frontend.
Your website will place advertisements in front of your visitors.

Take care when injecting dynamic content using plugins

Although this is a good thing for you to do but you must make sure you don't do it in a manner which causes layout changes.

It's best to position an announcement in the middle of the page. This will avoid shifting down your page's content.

If you're trying to find out whether the interactive content could be creating problems, try the tools for visualization mentioned above (e.g. the Layout Shift Generator).

If you notice that some content in a particular plugin triggers shifting layouts, it's possible to adjust those settings or switch to a different plugin.

For instance, some cookies' consent plug-ins perform better to others when it comes to layout changes. It's worth playing around using various software options if you're experiencing problems.

Make use of CSS Transform Property for Animations. CSS Transform Property for Animations when it's feasible.

If you're using animations for your website, they may be a common cause of layout shifts.

To stop complications caused by animations which cause layout shifts, make sure to utilize the CSS Transform tool for creating animations rather than using other techniques:

  • Rather than using to use the properties of the height along with the width properties, make use of transform: size()
  • If you're looking to shift elements, you can use transform to translate() rather than top, bottom right or left

It's more of a aspect of technology, therefore there's no reason to require this, unless you're adding it to your own CSS. To learn more, you can read Google's page on CLS and animations/transitions.

Summary

If your website is displaying the highest Cumulative Layout Shift score, it is important to fix it for a better user experience for human visitors as well as to improve the rank of your website in the results of Google.

One of the biggest difficulties is the inability to provide dimensions for embeds or images and difficulties with loading fonts. If you can solve these issues and you'll be well on your way to achieving a more favorable score.

  • It's easy to set up and manage the My dashboard
  • 24 hour expert assistance
  • The top Google Cloud Platform hardware and network is powered by Kubernetes for maximum scalability
  • Enterprise-grade Cloudflare integration to improve performance and security
  • The global coverage of the viewers can be boosted by up to 35 data centers, as well as 275+ PoPs all over the world.

This post was first seen on here