Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cumulative Layout Shift

Featured Replies

Hi all, 

I manage a website (not built by me) and whilst running reports I have had a CLS pop up site wide on a div. After the page loads this div, which is located at the top of the page, loads and causes the shift. I have gone back to the website builder and personally they have come back with a high price to rectify it and something I feel should be right from day one. Anyway, not here to question anyone's integrity I just need to know:

1. How easy do you think it is to fix?

2. How could I fix it? 

Please let me know what you need to help answer the questions. 

 

cLS.JPG

That's just one of the many issues with the site. It's a simple fix - shouldn't take more than an hour to do.

But the whole site is really poor. Especially on a mobile phone (which is what more people will be using). The online quote thing is awful as is the layout on the gallery pages.

Google is reporting a whole load of things need sorting: https://web.dev/measure/

But it's the UX that is of most concern. and the case studies will just make Google want to walk away.

Sorry to be all doom and gloom but the development company hasn't done you any favours.

Sorry for the delay. Thing is with CLS is it's in the name, 'cumulative', as the dictionary says "increasing or increased in quantity, degree, or force by successive additions.". I'm not being sarcastic, what you're seeing is the 'successive additions' which creates that score, I've never found one thing that is the single culprit.

I've taken a look at the main site and the biggest thing that stands out is you have lots of images without specified dimensions, however I'm guessing that the logo is pretty important above the fold. Without any dimensions specified the browser will need to download the image file, get the dimensions, and then the 'space' can be used as specified by the css. This delay is a contribution to shift, it has a lot of steps until it knows the space.

By defining the width and height of the image, e.g. the logo 'native' size is 319px X 106px, and that it's an <img>, the browser then 'knows' what it's dealing with, so it can make space even before the image is downloaded. However by defining width and height we're no longer responsive, but we can fix that.

<div class="logo">
<img src="/img/logo.jpg?1565698935" alt="logo" width="319" height="106">
<a href="/" class="anchor-box"></a>
</div>

... this will break the responsive, until we fix the image, an example;

.logo {
 width: 140px; 
}
.logo img {
 max-width: 100%;
 height: auto;
}

What this does is says the the container is 140px, the image can only be the max width of the container, and the height is whatever it needs to be to match the width of the container. So now even before the logo has actually downloaded the browser now knows that it has a 319px X 106px that needs to be displayed 140px X 47px, so it can reserve space before the file has even finished downloading.

Fix all of those first and then see the CLS score. 

Hope this helps you in the right direction :) 

Edited by BrowserBugs

and that logo shouldn't be a jpeg - if you can, use svg (very rare that you can't) , if not use png. 

14 minutes ago, davep said:

and that logo shouldn't be a jpeg - if you can, use svg (very rare that you can't) , if not use png. 

Unless it’s Wordpress (which doesn’t allow svg). I use webp for all images. 

3 minutes ago, fisicx said:

Unless it’s Wordpress (which doesn’t allow svg). I use webp for all images. 

does if you use a plugin e.g. https://wordpress.org/plugins/safe-svg/ not a problem if you know where svgs are coming from (i guess you could make some sort of permissions filter to not allow clients to upload svg but only site creators too? i think it might also be possible hard code the ability too - don't see why not - but not sure. 
And oops yes webp would be smaller and better than png :) (but still not as good as svg)

i understand the concerns with svg but having some sort of sanitizer built into the core wouldn't be that hard surely?! (instead of adding another plugin) 

 

Using SVG's shouldn't be a problem, there a several ways to use them in a CMS:

1. Use a file upload field
- upload the file
- call it into your templates wherever needed using an IMG tag or straight SVG tag

2. Use a textarea field
- paste SVG code, call into templates wherever needed

3. Use template "snippets" or whatever your CMS calls them
- useful for icons and other items that won't change often or where client doesn't need to change them
- create a template snippet, add SVG code
- call snippet template wherever you need in your main templates

You need a function in WordPress to add support, but they work fine. Webp isn't designed to optimise vector graphics, so you need both ideally.

20 hours ago, Jack said:

You need a function in WordPress to add support, but they work fine. Webp isn't designed to optimise vector graphics, so you need both ideally.

if i understood it correctly webp works with multiple algorithms so will also work better than png for vector graphics . Still svg would be the way to go. hmm might have to check (webp) now I've said that :) 

https://developers.google.com/speed/webp/docs/compression#lossless_webp

so it works like png in losslessly compressing contiguous areas of colour

ignore the screenshot below - accidently pasted that in instead of url. it's just a pdf test for Garamond ;) can't delete the stupid thing 
 

 

image.png

Edited by davep

1 hour ago, fisicx said:

When I switched to using webp my performance score went up considerably.

switched from what? jpegs? are supposedly to be considerably significantly smaller than jpegs, but for vector artwork it would nearly always be better as svg

WebP is for raster images, so it's a good substitute for JPG and PNG, but not for vectors. If you convert an SVG to WebP you lose all of the benefits of vectors, like being able to scale without adding weight, being able to apply colours with CSS etc.

The plugin I use converts png and jpg. The only place I’d use an svg is the logo so there doesn’t seem a lot of point setting everything up to do this. Especially as clients will just get confused.

I’m scoring 98/100 on Google’s performance tests. When I tested using an svg for the logo the score stayed the same.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.