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

clarify how navigation preload fetches can be measured using performance API #1361

Open
wanderview opened this issue Oct 19, 2018 · 0 comments

Comments

@wanderview
Copy link
Member

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.

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

No branches or pull requests

1 participant