clarify how navigation preload fetches can be measured using performance API
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 3.6k
- Forks
- 324
- Avg merge
- 14d 22h
- Merged PRs (30d)
- 1
Description
Sites using navigation preload may wish to measure when the preload starts relative to other events. Currently this information is exposed in the service worker context as a PerformanceResourceTiming entry. For example, this demo logs the navigation preload start time:
https://sw-pass-through.glitch.me/
It basically is doing this:
let r = await evt.preloadResponse;
if (r) {
// Log the performance data for the last entry matching this URL initiated for
// navigation. Probably the preloadResponse...
let list = performance.getEntriesByName(evt.request.url);
let entry = list.length ? list[list.length - 1] : null;
if (entry && entry.initiatorType === 'navigation') {
console.log("==> navigationPreload started at: " + entry.startTime);
preloadStartList.push(entry.startTime);
}
return r;
}
This works in both chrome and edge. I don't see where in the spec this behavior is defined, though. In theory the navigation preload may start before the service worker browsing context is created, so it seems a bit extraordinary that the preload request shows up in its performance entry buffer.
Another quirk I noticed. When the service worker needs to be started chrome will report a negative startTime for the preload, but edge does not (at least in my limited testing). This may not matter much in practice since it seems they are all still correctly relative to performance.timeOrigin, but its a small difference.
To be clear, I think we should support measuring the preload request. I just want to make sure its spec'd somewhere so we're all on the same page.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the navigation preload behavior described in the issue and compare it with the PerformanceResourceTiming API, using the linked demo as a reproduction. Trace how preloadResponse and performance.getEntriesByName() are expected to interact, including the negative startTime difference, and document the applicable specification behavior and interoperability expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100