resource-timing icon indicating copy to clipboard operation
resource-timing copied to clipboard

Resource initiator information to enable creation of dependency trees

Open yoavweiss opened this issue 3 years ago • 2 comments

many years ago we talked about extending the initiator information that resource timing exposes to enable creation of dependency trees from RUM data. Those dependency trees could then enable better understanding of the resource loading of the page in the wild, and enable interesting analysis and optimizations.

For example, understanding which resources are responsible for the loading of others, can result in understanding that early discovery of the resources can speed up others, and encourage developers to preload them.

yoavweiss avatar Apr 01 '21 21:04 yoavweiss

Here's the use case involving ServiceWorker I mentioned during last call:

  • A SW (sw.js) controlled page has a script foo.js that requests /bar
  • SW intercepts all requests via the fetch handler
  • Several pages might be open requesting the same /bar Question: Who should be considered the initiator when a SW intercepts requests?
  1. sw.js ?
  2. foo.js ?

I believe we have 2 contexts here: the page and the SW. IMO, regardless where RT entries are queried from, both should show foo.js as initiator. Reason being the fact that with a SW intercepting all requests, all entries would be pointing to sw.js which ultimately does not help building an accurate dependency tree.

marcelduran avatar May 04 '21 19:05 marcelduran

Some thoughts on scenarios that a more accurate dependency tree could enable:

  • The data would enable a RUM version of the RequestMap tool via @simonhearne
  • RUM tools could use it to enhance their analysis, such being able to more accurately bucket page weight costs by first- and third- party libs, or suggest which third-parties to cut and their full costs
  • CDNs could probably use this information to make smarter decisions about pre-fetching or pre-loading content for visitors, i.e. only load X CSS if Y JavaScript was loaded
  • Security products could better backtrace rogue requests

Would definitely love to see if this is a possibility!

nicjansma avatar May 22 '21 03:05 nicjansma