Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout-shift-elements score should match CLS score. Add more CLS rootcause analysis #14583

Closed
tunetheweb opened this issue Dec 5, 2022 · 6 comments
Assignees
Labels

Comments

@tunetheweb
Copy link
Member

tunetheweb commented Dec 5, 2022

Feature request summary

Currently we have two CLS audits: one for not setting height and width on images, and one for the elements causing most shifts.

Take cnn.com, which currently shows this for mobile:

CLS audits highlighting the width and height image audit as failing

And when the "Avoid layout shifts" audit is expanded you get this:

CLS audits with the layout shifts audit expanded

You can see here the "Image elements do not have explicit width and height" audit is not actually contributing to CLS (at least for the above the fold content that Lighthouse shows be default, but a <div> IS causing CLS - with a massive 0.135 (the entirety of the CLS captured by Lighthouse).

Lighthouse is highlighting the wrong issue here, which can lead to confusion.

I would suggest we reduce the image audit to amber when there are no equivalent images in the layout shifts audit (though keep as amber as it may affect below the fold content), and we highlight the layout shifts audit in red when the total CLS is above the good barrier of 0.1:

CLS audits with the correct area to concentrate on highlighted

For bonus points it could highlight the shifts above the 0.1 limit in red (ideally with a warning symbol too as well so it's not just colour highlight).

CLS above 0.1 highlighted in red

What is the motivation or use case for changing this?

Lighthouse is currently not highlighting the real issues in these cases.

How is this beneficial to Lighthouse?

Allow Lighthouse to more accurately reflect content affecting CLS making it more useful and less prone to falsely identifying non-issues.

@connorjclark
Copy link
Collaborator

connorjclark commented Dec 5, 2022

I would suggest we reduce the image audit to amber when there are no equivalent images in the layout shifts audit (though keep as amber as it may affect below the fold content), and we highlight the layout shifts audit in red when the total CLS is above the good barrier of 0.1:

It's a good idea, but this comes down to "can we attribute the root cause of an arbitrary layout shift", which we can't right now (granted, we haven't tried in awhile, maybe something is new wrt recent Performance Insights work?). For each shift in the Layout Shifts audit, the elements moving around aren't necessarily the image elements lacking width/height attributes – so we can't determine if any given image in the "missing width/height" audit is associated with the observed layout shifts.

@tunetheweb
Copy link
Member Author

That’s a very good point!

Thoughts on the second suggestion of promoting the “layout shifts” section beyond “informational” which it’s clearly identifying CLS limit-breaking shifts? Agreed it’s the effect, rather than necessarily the cause but still feels important to highlight more to me.

@connorjclark
Copy link
Collaborator

connorjclark commented Dec 5, 2022

Yeah, we should perhaps set the score of that audit to be the CLS score to match the metric pass/warn/fail state.

@connorjclark
Copy link
Collaborator

We're gonna explore what we can do to give a best-guess for root-cause attribution in Lighthouse this quarter. CDT has done some work on this recently, although it's in an internal repo.

@tunetheweb
Copy link
Member Author

I think highlighting the shifts themselves more when they are large could be an easier option, and a big win, and avoid the complexities of trying to attribute those fixes.

@paulirish paulirish changed the title Highlight layout shifts that cause a poor CLS better Layout-shift-elements score should match CLS score. Add more CLS rootcause analysis Mar 7, 2023
@adamraine
Copy link
Member

This is done in #15703 which adds root cause analysis. We have also changed the scoring methodology so layout shifts are highlighted in red and unsized images are highlighted in orange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants