-
Notifications
You must be signed in to change notification settings - Fork 426
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
onLCP does not work on prerendered pages #268
Comments
@philipwalton I think this is due to a combination of this: Lines 54 to 58 in dfbd06e
And this: web-vitals/src/lib/bindReporter.ts Line 40 in dfbd06e
As the LCP time for a prerendered page should always be less than the activation time, we get a negative LCP, and that is then filtered out. We should clamp it to 0, same as we do for TTFB. I've tested with a copy of @domenic 's demo page here and it seem's to work: https://prerender-demos.glitch.me/ Presumably should do same for FCP too. Happy to put together a PR if you agree. |
Sure, if you have time. Otherwise I could probably do it pretty quickly later today. Update: ahh, I see you submitted #270 already. I'll take a look later. |
Steps to reproduce:
document.prerendering
was logged as true), but no LCP is logged.So it seems like if the page is loaded while prerendered, onLCP is never called. Maybe this is related to the README saying
I noticed that there is some special handling for bfcache restore in https://github.com/GoogleChrome/web-vitals/blob/main/src/onLCP.ts#L92-L106 . Maybe there should be something similar for prerendering activation? (Prerendering activation can be detected using the
prerenderingchange
event onDocument
.)The text was updated successfully, but these errors were encountered: