-
Notifications
You must be signed in to change notification settings - Fork 36
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
Resource direct lookup support #255
Comments
Why is performance.getEntriesByName(img.src) not good enough in the above example? |
In the above example, it would be sufficient if we can guarantee it was the only resource with that name. However, that isn't a good assumption to make. Retries, duplicate loads (like avatars used in a few places), prefetching, POST requests, etc. are all scenarios that make name alone unviable. What's more, it seems that the resource entries of various entryTypes aren't always added at the same point so you can't apply the same logic to all scenarios. For example, the perf entry for the image resource is there at the point of onload (allowing the example above to work) but for Fetch, it won't be there during the first then() handler so it needs observer logic like, "get me the next resource with this name." These inconsistencies add to the unreliable nature of name alone and now require startTime requirements as well. |
A resource used in a few places won't trigger multiple entries. It should be cached and reused if it's the same resource. But yea there are cases where there could be multiple entries with the same name. I just don't think the API you are suggesting is feasible. You mention the fetch example. Where would you set the resourceIdentifier in that case? If an img src is later set then would you expect the img resourceIdentifier to change accordingly? Where would you query this for CSS? Etc. |
For some reason, I missed that understanding around only one entry being put in the entries list (could I trouble you for a link to the spec around the rules deciding that?). But, to be honest, I think that might add to the complexity here. How would I know which resource to attribute to an entry and which should I attribute to another one (ala it's cached)? In that case, I'd expect to be able to identify each resource with its associated performance entry and know if it initiated it or if it was cached/linked to that other. <- I think it's worth deferring that nuance for the time being though to start simple.
To be clear, I don't have a thought out suggestion for this API - just an example of what that might look like to illustrate the ask/ticket needs. So that very well may be true but I never expected it to be doable out of the gate :) But thinking about it, IF we went with an identifier key that we'd used to look up the entry (let's keep with the I am entirely unwed to this idea and open to better alternatives for direct lookups or differentiation capabilities. |
Dropping this raw, very loosely thought through idea.. perhaps the resource performance entries contain an array of ids for resources which have id fields. So if any resource network request is triggered by an object containing an .id field, that identifier is added to this list if it's serviced by this performance entry. There aren't standard id fields for some object types so I'm unsure of what it would mean to introduce that or if it's a non-standard field that can be leveraged as it's only a reference point that doesn't have side-effects that would break future standardization of an id field. |
One solution for this problem I've been using was assigning requests IDs and inserting those into no-op URL params. The solution is not pretty and requires some custom request & getEntries link management. e.g.: XHR to
I believe this could be adapted to resources initiated via regular html tags, e.g.: tracking impression images.
|
With the increasing usage of Graphql, we are seeing this more often as well. The entry name is the same for dozens of requests on every page load. Since they are all POST requests the only differentiator is the body of the request.
I'm currently using the QS string hack posted above, but many applications reject unknown query string entries. |
Short (bad-version) idea: Have a way to associate a resource with its performance entry via the event handlers for the resource itself. This could be a callback of sorts or an identifier/reference. But something that helps me map this resource to its timing.
When building tooling to analyze the performance of requests, we need to measure a few things - status code, request options, response bodies, etc. In almost all perf tooling, we will also need to pull what information we can from the performance entries. As of right now, that needs to be some level of heavily nuanced fuzzy logic around timing and order (which can be different cross-browser and across the different resource types). This makes things pretty challenging and less reliable than we would like.
as a trivial ("bad version") example:
I'm less interested in what it looks like personally but meeting that goal of the direct lookup. I think it's totally acceptable for the entry to not be there yet (invalidating the above example for all usecases) and we can use that identifier in conjunction with the performance observer to associate resources.
The text was updated successfully, but these errors were encountered: