-
Notifications
You must be signed in to change notification settings - Fork 42
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
Report Web Vital metrics on every chance #949
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inancgumus
changed the title
Fix/914 hide page on close
Force page unhide to produce more Web Vital metrics
Jun 23, 2023
inancgumus
changed the title
Force page unhide to produce more Web Vital metrics
Force page hide to produce more Web Vital metrics
Jun 23, 2023
inancgumus
changed the title
Force page hide to produce more Web Vital metrics
Report Web Vital metrics on every chance
Jun 23, 2023
With this change, the Web Vital callbacks will be called for all changes. instead of waiting for them to complete. See this comment: If the `reportAllChanges` configuration option is set to `true`, the `callback` function will be called as soon as the value is initially determined as well as any time the value changes throughout the page lifespan. https://github.com/GoogleChrome/web-vitals/blob/5973d51be39ab0020268aa2397ead0962eedf4c2/src/onCLS.ts#L43-L46
inancgumus
force-pushed
the
fix/914-hide-page-on-close
branch
from
June 23, 2023 13:56
1a854b5
to
d0b6d21
Compare
ka3de
approved these changes
Jun 23, 2023
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.
LGTM.
ankur22
approved these changes
Jun 23, 2023
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.
Thanks for @inancgumus. I'm happy to trial this out with #950 to ensure that the measurements are still accurate 👍 LGTM 🙂
inancgumus
added a commit
that referenced
this pull request
Jun 23, 2023
This brings back the hack we removed from PR #949. I've also added a test for it. When we remove the hack, the test fails, otherwise passes.
ka3de
pushed a commit
that referenced
this pull request
Jul 11, 2023
This brings back the hack we removed from PR #949. I've also added a test for it. When we remove the hack, the test fails, otherwise passes.
ka3de
pushed a commit
that referenced
this pull request
Jul 11, 2023
This brings back the hack we removed from PR #949. I've also added a test for it. When we remove the hack, the test fails, otherwise passes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First commit explanation
Note: We've decided to remove the first commit as the second commit already fixes the issue. Here's the changes from the first commit in case we need it again.
The first commit forces the Web Vital metrics to get triggered on
page.Close
. The page is closing anyway, so there should be no harm in hiding it before it gets closed. Please see this description and this comment for the details. It turns out that usingpagehide
is the recommended way here. What they really recommend is to batch the events instead of processing them one by one. Anyway, this can shed light on why this fix works.Second commit explanation
Additionally,
CLS
should/can be called multiple times.This 2nd commit uses this advice and sets the callbacks to report metrics all the time. See this link for more information.
Results
Before:
After:
I used the same script from this comment, but without
page.reload()
! So here it is again.Test script