More than 50,000 developer David Walsh blogs are found every month from all over the world to learn JavaScript tricks and solve problems in their code. Unfortunately, some of them have a slow experience on the site.

David detects his primary web Vittels as well as overall performance performance Request the matrix. Recently, we saw that its CLS performance scores were very slow for both desktop and mobile users.

Wait, what is CLS?

The overall setting shift (CLS) is a Primary web important Performance matrix. It does not measure direct load time, rather than how much it measures a page Shift When it is filled. You have definitely seen it and are angry with it. These shifts make a site Feel Slow to a user.

The CLS and the rest of the basic web vitals are very important. Not only because they measure the user’s experience, but also because they affect a site’s page in search. And there is a life for everyone with search traffic bloggers, media sites, e -commerce stores, and website.

If we can solve the site’s CLS problem, we will give readers faster experience, and promote search rating so that David can help more people. Looks like a great incentive, let’s find out.

Crash with Google Lighthouse

Many, many developers, will use a tool like Google Lighthouse, to find a performance problem. I released a lighthouse report on David’s site, and here I got.

A perfect score! Let’s pack it and go home.

The hassle she is Google Lighthouse is a lie. The real users will not have this performance. This score represents only one test, from my powerful computer, in the United States, on a sharp broadband connection.

David’s real users come from all over the world, various devices and networks and daytime. Their performance experience is far from perfect. That’s why we need to get Real user supervision For performance, otherwise we can never know that there is a problem.

Where are CLS problems?

David has been writing for a long time and has hundreds of posts on his site. The application matrix tracks the CLS score per page so we can zero the problems.

The largest traffic page is the root page, and it has good CLS. But many of his posts, such as Play Grand Po World And Purna Hub Interview There are disturbing CLS scores. We can also track the responsible elements of the CLS, and for most posts its main > article > p. This means that the first paragraph of the article is changing. Why will it do it?

What is shared in these posts with the worst score of CLS? Photos are a very common reason for CLS problems because the browser does not always know how big the picture is until it is downloaded. The browser assumes that it is 0x0 unless it has its image, then Shift Everything around it to build a room.

Many photos posts will change several times as each photo was downloaded and the article was transferred to replace new content.

To use images correctly for CLS

Layout shifts while using photos L, we need to indicate the browser how big the images will be. The browser will use these gestures to save space in the layout for icon when it ends downloading.


Note that width and height are determined as their own attributes – not part of the style tag. These attributes have set both the proportion to use the basic size of the icon as well. You can still use CSS to make the image bigger or small from here.

Also note that there is no px Unit specified

Image size in WordPress

David Walsh. The name is hosted on WordPress, where there are some built -in tools to do so. We can use wp_image_src_get_dimensions He is using the dimensions of the images and add them to the markup.

To prove it works

David had changed this photo a few days ago, and we are already seeing improvement. The CLS has dropped 20 % to 0.123. We are now closer to the CLS’s “good” limit.

There are still some problems to be set up around the font, but it will be another time and a story for another post.

If you want to improve the actual performance of your site, or are worried about losing your SEO juice with basic web key issues, take a look Request the matrix. In fact, this has been found in this to fix your performance and actionable points.

Also it’s free, so it’s going for it.

Todd Gardner

About Todd Gardner

Todd Gardner is a software entrepreneur and developer that has made numerous profitable products. He emphasizes simple tools, maintaining software, and risking complexity with risk. He is the track JS and application matrix’s cockyer, where he helps to create thousands of developers fast and more reliable websites. He also produces a PubconF software comedy show.