DEV Community

Cover image for The curious case of the paragraph with the bad CLS
Fredrik Bergqvist
Fredrik Bergqvist

Posted on • Originally published at bergqvist.it

The curious case of the paragraph with the bad CLS

I recently migrated my personal website from Next.js to 11ty, it was a great experience, which I will write more about in a later blog post.

There was just one issue. The PageSpeed performance score actually went down. 😨

Link to PageSpeed.web.dev

Mobile performance was looking great, a 4 x 100 score, but desktop performance was hurting. The problem also only occurred on the blog post list page, not on the individual blog post pages, and only when the page width was greater than 960 pixels, when the max with of the content was set to a fixed value and margin auto.

After some digging, the culprit seemed to be a paragraph at the end of the blog post list, containing a link to older posts.

List of elements affected by the layout shift taken from devtools

This is a version of the start page with the paragraph: Click for some bad CLS and the version without: Click for no bad CLS

When fiddling with it, I found that any block element (or even inline-block), would cause the issue, but using a span would not trigger it.

Now, I do understand that this, in reality, is a non issue, and really only proves the point that blindly following performance scores is not always the best way to go.

But I am still curious about why this is happening. If you have any insights, please let me know.

To be continued... (I hope)

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay