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

Report 'prerender' navigation type accurately #75

Merged
merged 3 commits into from
Jun 7, 2023

Conversation

ajhyndman
Copy link
Member

In the case that a page was pre-rendered, we should report the 'prerender' navigation type, as defined in the W3 specification.

https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming/type
https://w3c.github.io/navigation-timing/#sec-performance-navigation-types

const navigationType = isBfCacheRestore
? 'back_forward'
: // @ts-ignore activationStart is an experimental property
navigationEntry.activationStart > 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check navigationEntry.type instead? If it's already prerender, then just pass it on. I guess I am wondering if there will be able mismatch between navigation type = prerender and activationStart > 0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did check this, but it turns out Chrome does not actually report 'prerender' correctly. This is in conflict with my reading of the spec.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://developer.chrome.com/blog/prerender-pages/#detecting-prerender-in-javascript

image

I guess checking activationStart it is then. Do we need to check document.prerendering for prerendering page (rather than prerendered page). I guess maybe we don't since we restart measurement on prerenderingchange anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Oh, nice find.

Yes, that's right. The document.prerendering value will only be true during the prerender, and we never report TTVC before prerendering has finished.

@ajhyndman ajhyndman merged commit 79615ce into main Jun 7, 2023
@ajhyndman ajhyndman deleted the prerender-navigation-type branch June 7, 2023 15:28
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.

2 participants