-
Notifications
You must be signed in to change notification settings - Fork 134
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
✨ [RUMF-777] implement Cumulative Layout Shift #628
Conversation
const { stop: stopCLSTracking } = trackLayoutShift(lifeCycle, (layoutShift) => { | ||
cumulativeLayoutShift = (cumulativeLayoutShift || 0) + layoutShift | ||
scheduleViewUpdate() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { stop: stopCLSTracking } = trackLayoutShift(lifeCycle, (layoutShift) => { | |
cumulativeLayoutShift = (cumulativeLayoutShift || 0) + layoutShift | |
scheduleViewUpdate() | |
}) | |
if (isLayoutShiftSupported()) { | |
cumulativeLayoutShift = 0 | |
const { stop: stopCLSTracking } = trackLayoutShift(lifeCycle, (layoutShift) => { | |
cumulativeLayoutShift = cumulativeLayoutShift + layoutShift | |
scheduleViewUpdate() | |
}) | |
} |
then we would avoid to handle undefined case in callback.
It could probably remove the need to check the support in the track function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to handle the undefined
case (for typings), but it's a bit easier to follow, so I just used a !
operator. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Motivation
Expose the web-vitals CLS on all views
Changes
Testing
CI + manual tests
I have gone over the contributing documentation.