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

Ensure CLS is only reported if page was visible #149

Merged
merged 1 commit into from
May 13, 2021
Merged

Conversation

philipwalton
Copy link
Member

Currently, in CrUX, CLS will not be reported for a page if it does not report any FCP value. This was done to filter out pages reporting 0 when they were loaded in the background and never focused.

However, matching the CrUX behavior here is problematic for two reasons:

  • CrUX is actually under-reporting CLS because pages that were loaded in the background and later focused can still have layout shifts that affect the user experience. Yet these pages will not report FCP, and thus those layout shifts are ignored. (CrUX plans to fix this in the future.)
  • Many users of this library want to capture CLS, but they may not be interested in capturing FCP. Yet if the getCLS() function is coupled to the FCP logic, the final bundle size for those users will be larger than it needs to be for users only interested in the Core Web Vitals.

To address both of these points—and anticipate the changes CrUX plans to make—this PR updates the logic to report CLS if the page was ever visible at any point in its lifecycle.

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

Successfully merging this pull request may close these issues.

1 participant