Cumulative Layout Shift: Improve Core Web Vitals CLS Score

Written by Shreoshe Ghosh

Updated on Sep 8, 2020
Category: Technical SEO

Have you ever been in a situation where the checkout page vanishes before you click on the “place my order” button? 

Yes! It’s frustrating, and the truth is, it happens way too often and with too many of us. 

Thankfully, as always, Google prioritizes user experience above everything else, which is why it will roll three new performance metrics as a part of its core web vitals, starting in 2021.

The Core Web Vitals is designed to measure loading speed, interactivity, and visual stability of a page.

Three metrics represent these:

  1. Largest Contentful Paint (LCP)
  2. First Input Delay (FIP) and,
  3. Cumulative layout Shift (CLS).

Let’s understand CLS from both user and webmasters (SEO) point of view.

What is Cumulative Layout Shift?

The Cumulative Layout Shift (CLS) represents the visual stability of a website. It measures the amount of insignificant layout shifts on a page. 

Unexpected layout shifts are the result of a web page moving around itself without user input. 

Cumulative Layout Shift is a kind of indicator(Signal) for you to fix the problem by measuring how often an unexpected movement of page elements affects the user experience. 

A shift in a layout can occur any time when a visible element changes its position from one rendered frame to the next.

Let’s try to understand the common meaning and define in simple words “Cumulative Layout Shift”:

Cumulative is an increase in quantity. 

The layout is the Frame, and

A shift is a change in position.

Simply put, Cumulative Layout Shift is a total sum of all individual frame changes in website design positions.

Cumulative Layout Shift scores

Image sourced from web.dev

The standard CLS score should be below 0.1. A good threshold to measure the same is the 75th percentile of page loads across mobile and desktop devices.

In the image above, it is clear that 

As per Google:

  1. If the CLS score is more than 1.0, it is a good signal. It means your site has no issue with any layout shift.
  2. If the CLS score is between 1.0 to 0.25, it means your site needs certain improvement in the visual layouts.
  3. If the CLS score is less than 0.25, it is a poor signal, which also means that the visual element’s movement is occurring very frequently.

How is Cumulative Layout Shift Calculated?

Google computes the CLS of a page by calculating the impact fraction and distance fraction for each unexpected layout shift. 

Impact Fraction of CLS

It measures the amount of space an unstable element takes up in a viewport area between two frames.

Formula to calculate the Impact Fraction for CLS

To Calculate the Layout Shift Score, we need Impact Fraction.

impact fraction CLS Formula with example

How to calculate Impact Fraction for CLS? Graphical representation will help you understand impact fraction better.  

impact fraction CLS Formula with example 1

Impact Fraction = [Area of Impact Region] / [Area of Viewport]

Impact Fraction = [330 x 490] / [375 x 667]

Impact Fraction = [161700] / [250125]

Impact Fraction = 0.645

Distance Fraction of CLS

It is the measure of the amount of space that the page element has moved from the original position to the final position that basically shifts in layout.

To avoid excessive penalizing cases, shift in large elements by a small amount taken into account by introducing Distance Fraction.

Formula to calculate the Distance Fraction for CLS

distance fraction CLS Formula with example

How to calculate the Distance Fraction for CLS? Graphical representation will help you understand distance fraction better. 

distance fraction CLS Formula with example 1

Distance Fraction = [Max. Move Distance] / [Height of ViewPort]

Distance Fraction = [120] / [667]

Distance Fraction = 0.179

Formula to Calculate Google CLS Score

The Cumulative Layout Score is calculated by multiplying the Impact Fraction by the Distance Fraction:

i.e. Cumulative Layout Shift (CLS) = Impact Fraction*Distance Fraction.

CLS = 0.645 x 0.179

CLS = 0.1154

The CLS score keeps rising as the impact and the distance fraction increases. 

Let’s try to understand,

Cumulative Layout Shift with a simple example. 

You visited a site and saw something interesting to read. You go ahead to click on the link, but just as you were about to click the link, it shifts down in the web page by half an inch, and you end up clicking on an ad that was placed just above it. 

unexpected layout shift

Source:nitropack.io

Sounds unfair, right? It’s an unexpected layout shift.

It only means that you will be redirected to some unwanted landing page from where you have to come back to the original web page.

We also have something known as the expected layout shift. 

It happens when you click on something on a web page, and it changes the current layout of the page.

For example, you go to a blog looking for a particular piece of information. 

As soon as you enter the topic name in the search bar, it will retrieve a particular blog post where you’ll find the required information or come up with a couple of blog posts related to the topic.

unexpected layout shift 2

Source: nitropack.io

This is an expected outcome from the web page and can be considered an expected layout shift. 

What Causes CLS Issues? 

As per Google, the search engine giant, there are 5 possible reasons for Cumulative Layout Shift:

1. Images and Videos without dimensions

It is advisable always to specify the width and height of your images and videos. 

You can also utilize CSS aspect ratio boxes to allow the browser to allocate the right amount of space on the web page while the image is loading.

2. Ads, embeds, and iframes without dimensions

Ad sizes can boost revenue through high CTR. However, this can compromise with the quality of user experience by pushing the content down the page. 

This layout shift can be mitigated by reserving space for ad slots, eliminating shifts by reserving the largest possible size for the ad slot or choosing the ad slot’s best possible size based on historical data. 

3. Dynamically injected content

Avoid inserting any new content above existing content, unless it is in response to user interaction. This will ensure any layout shifts that occur are always expected rather than triggering the image or text to move unexpectedly.

4. Web Fonts causing FOIT/FOUT

Try using font:display values with your custom fonts like auto, swap, block, fallback, and optional, to prevent unnecessary layout shifts. 

If you want to be 100% sure there is no layout shift happening, you should use font:display in conjunction with <link rel=preload>.

Any element that uses that font will be hidden until the font asset has been downloaded fully, is known as FOIT (Flash of invisible text).

foit-fout-animation

Animation source:malthemilthers.com

The display of a fallback font in the font stack until the custom one loads is known as FOUT(Flash of unstyled text).

5. Actions waiting for a network response before updating DOM

Always go for “transform” animations for animations of properties that trigger layout changes.

How is CLS Influenced Through Ads?

To deal with ads that cause CLS, you need to style the element where the ad is going to show.

Therefore, if you style div, (The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements – which is then styled with CSS or manipulated with JavaScript) the image or video division in a WordPress or any website element with a specific height and width measurement, your ad will be constrained within the mentioned dimensions only.

If an element containing an ad doesn’t show the ad, you can set it in a way that an alternative banner ad or a placeholder image can fill the vacant space.

Alternatively, an ad may fill the entire row on the top of a column in the right or left gutter of the page for certain layouts. 

If the page doesn’t show up, there won’t be a shift and it won’t make any difference on mobile or desktop.

However, you should note that it depends on the theme layout and you’ll have to test it out if there’s an issue with the ad inventory. 

How Can CLS Slide During Web Development?

Google CLS can slip through the development stage. Here’s what can happen.

Many of the assets needed to render a web page are loaded onto a browser’s cache. 

The next time a developer visits the page under development, they won’t notice a layout shift since the page elements are already downloaded. 

It is therefore recommended to have a measurement in the field or the lab. 

Tools to Test or Measure Cumulative Layout Shift 

Cumulative Layout Shift Performance website metrics can be measured in any of the following ways:

Field Tools

In the field: on real users actually interacting with the page. It can be measured using the following Field tools:

Chrome User Experience Report

It provides user experience metrics for how real-world Chrome users experience popular destinations on the web. 

PageSpeed Insights

It analyses the content of a web page and generates suggestions to make that page faster than before.

Search Console (Core Web Vitals report)

It shows how your pages perform based on real-world usage data (sometimes called field data).

Lab Tools

In the lab: using tools to simulate a page load in a controlled environment can be measured using the following Lab tools:

Chrome DevTools

It can help you edit pages on-the-fly and diagnose problems quickly, which ultimately enables you to build better websites faster.

Lighthouse

It is an open-source, automated tool for improving the quality of web pages. You can run it against any web page, public, or requiring authentication. It has audits for performance, accessibility, progressive web apps, SEO, and more.

WebPageTest

Run a free website speed test from around the globe using real browsers at consumer connection speeds with detailed optimization recommendations.

According to the web.dev; Caution: Lab tools typically load pages in a synthetic environment and only measure layout shifts during page load. As a result, CLS values reported by lab tools for a given page may be less than what real users experience in the field.

Quick Tools to check Cumulative Layout Shift

1. CLS in GIF format from Defaced Tool by Chris Johnson to Identifies the problematic LS.

2. Cumulative Layout Shift calculator 

Conclusion

Understanding Cumulative Layout  Shift (CLS) will help you offer a better user experience in the coming days. Since the metric is a part of Core Web Vitals to improve UX and is scheduled to become a ranking signal in 2021, it is important to understand its importance and impact on your site. 

About Shreoshe Ghosh

Shreoshe has been crafting and editing content on multiple niches for more than 4 years. She specializes in blogging on SEO and digital marketing. When she isn’t writing, you can find her working for the welfare of street animals. Reach her @ Mail | LinkedIn | Facebook or View all posts by Shreoshe

You May Also Like…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *