-
Notifications
You must be signed in to change notification settings - Fork 461
Experimental Soft Navigation support #308
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
base: main
Are you sure you want to change the base?
Conversation
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.
Hey, this is excellent work. Quite a bit to get right, thanks for the effort!
I only review the CLS changes, and I think there's a potentially cleaner way to do it. I didn't review the specifics of the other metrics since I the change would alter a lot there too, so wanted to discuss that first.
Basically:
- I think the observe() helper, which all metrics use, should be the only place where we look at navigationID and split entries whenever it changes. See: https://github.com/GoogleChrome/web-vitals/blob/main/src/lib/observe.ts#L52
- Whenever navigationID changes (or, the first time for initial nav), that helper can look up pageURL, etc, that way we have shared cache for all metrics
- Each metric implementation right now already uses helpers like onFCP, onHidden, onBFCacheRestore... in order to "finalize" and/or "reset" its metrics. I think we could have another helper like onNavigate(), which can be used to flush/reset metrics.
One tricky bit may be that the onNavigate() helper needs to be called before any new Entry that uses that navigationID, and you could have entries with different navigationID in a single PerformanceObserver callbacks, especially when using buffered entries.
That said, I think all this code made be fragile to such cases and needs careful testing.
Keep at it!
That’s for the review @mmocny ! I’ve cleaned it up quite a bit further so it’s a bit smaller now. Have another look if you get a chance and see what you think now. |
Hey! I'm super excited about this work. Could you republish the branch? |
Well that's embarrassing! Republished to the |
Hi @tunetheweb, Thanks a lot for introducing support for Soft Navigations in the library! While exploring the new features, I noticed something interesting. It seems that not all changes are being reported when To handle that scenario, I've slightly updated the |
Updated this branch to v4 code. |
Warning: This branch is likey to stay in draft for some time, and not to be merged into
main
until the Soft Navs experiment completesFixes #119
Implements experimental support of Soft Navigations to the library: