Skip to content

Conversation

@brendankenny
Copy link
Contributor

@brendankenny brendankenny commented May 25, 2021

Fixes #12350, part of #11866

As discussed in that issue, CLS is being switched to the max-session-gap1s-limit5s variant with LayoutShift events from the whole frame tree ("all frames") to align with the broader web-vitals CLS change.

The new version will result in unchanging or better CLS values for all users by design, but since Lighthouse currently only measures CLS during page load, most users won't see much meaningful change in their CLS (we currently estimate that about 5% of sites will go from a poor to average rating, and about 3% of sites will move from average to passing).

This PR touches a lot of files, but the primary change is moving the winning variant in layout-shift-variants to the cumulative-layout-shift computed artifact (with much of layout-shift-variants-test making a similar journey) and then updating a ton of test expectations.

The computed artifact also exposes a cumulativeLayoutShiftMainFrame for a only-main-frame version of the metric, and an oldCumulativeLayoutShift (edit: we went with totalCumulativeLayoutShift) which is the original CLS for developers who still want to track it. I can't remember what we finally decided to call that and #12350 isn't clear, so that'll be the first thing we can fix in review :)

Comment on lines 118 to 120
// The original Cumulative Layout Shift metric, the sum of main-frame shift events from the entire trace.
const oldCumulativeLayoutShift = mainFrameShiftEvents
.reduce((sum, e) => sum += e.weightedScore, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calculateOldCumulativeLayoutShift?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah, thanks

@brendankenny
Copy link
Contributor Author

The computed artifact also exposes a cumulativeLayoutShiftMainFrame for a only-main-frame version of the metric, and an oldCumulativeLayoutShift which is the original CLS for developers who still want to track it. I can't remember what we finally decided to call that and #12350 isn't clear, so that'll be the first thing we can fix in review :)

ok, we're going with totalCumulativeLayoutShift as of right now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update CLS definition

4 participants