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.
Chrome started rolling out Omnibox prerendering in version 101, via the Prerendering API.
This API has timing implications for prerendered pages—specifically, all load-related metrics should be relative to when the page was "activated" rather than when it started loading (for non-prerendered pages these values are the same).
To support prerendering in this library, this PR updates the
onLCP()
,onFCP()
, andonTTFB()
functions to report their value relative to theactivationStart
time via the Navigation Timing API extension rather than from the time origin of the page.This PR also adds a new
prerender
value to thenavigationType
property of theMetric
object, so developers can be aware when prerendering is having an effect on the metric values and filter by just those values (or exclude them from a report if they wish).One important implication of this change is that the value reported by the library may not match the value reported by the
PerformanceEntry
object in theMetric.entries
array. For example:The values in the
entries
array are never modified, so if someone wanted to report both the "raw" LCP value and the LCP value relative toactivationStart
they could do so using the values from theentries
array.One situation where this may be desirable is the TTFB metric, since prerendered pages will often get their first byte of content before activating, this means the TTFB value will be zero. In these cases developers may choose to report the underlying Navigation Timing API value, including
activationStart
to help them diagnose and fix network issues. However, when using TTFB as a sub-component of LCP, it's important to compare them using the same start time (e.g.activationStart
).