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

Initiator is not well defined #69

Closed
yoavweiss opened this issue Oct 10, 2016 · 8 comments
Closed

Initiator is not well defined #69

yoavweiss opened this issue Oct 10, 2016 · 8 comments

Comments

@yoavweiss
Copy link
Contributor

I've been looking at specific ways to add more detailed initiator info that would enable getting the dependency tree info from resource-timing (as briefly discussed during TPAC).

When digging deeper into the spec and the current definitions, I found some unfortunate surprises:

  • The term "initiator" is not really defined in the spec
  • initiatorType sometime points at the type of the resource itself, and sometimes points at the type of the initiator (specifically, with the "css" initiator type)
  • Fetch contains the concept of "initiator", which is not related to what we need here in any way.

Furthermore, for the purposes of a dependency tree, initiator definition needs to vary from the one practiced with initiatorType (and match more closely what happens in the various browser dev tools):

  • If an element triggered a resource download and was part of the HTML's markup, the "dependency initiator" should be the HTML itself
  • If an element triggered a resource download, but was added to the HTML by a JS file, the "dependency initiator" should be the JS resource (or maybe JS resources, if the addition was the result of multiple JS resources executing)
  • Cases which now get "css" as initiator type, the "dependency initiator" should point to the CSS resource.
  • If a download was triggered by XHR/Fetch, the "dependency initiator" should point to the JS resource(s).

I think that for the purposes of initiatorType, we'd better define the behavior as it is currently shipped.

For the purposes of the "dependency initiator", we probably need to define something slightly different. As initiatorType is already shipped and the term "initiator" seems to be overloaded, we probably also want to find a new name.

@igrigorik
Copy link
Member

I think that for the purposes of initiatorType, we'd better define the behavior as it is currently shipped

Agreed, I don't think we can change it significantly. That said, what would you propose we change or update with respect to current definition?

Aside: I propose we focus this thread on the above and resolve it separately from a design discussion on what we could/should do to tackle the "dependency tree" use case. For the latter, let's open a new thread and describe the use case(s) and what's needed to enable them.

@igrigorik igrigorik added this to the Level 2 milestone Nov 11, 2016
@igrigorik
Copy link
Member

Taking a second pass at this...

I think that for the purposes of initiatorType, we'd better define the behavior as it is currently shipped.

Spec: https://www.w3.org/TR/resource-timing-2/#dom-performanceresourcetiming-initiatortype

On getting, the initiatorType attribute must return one of the following DOMString:

  • The same value as the localName of that element [DOM], if the initiator is an element.
  • "css", if the initiator is a CSS resource downloaded by the url() syntax [CSS-SYNTAX-3], such as @import url() or background: url().
  • "xmlhttprequest", if the initiator is an XMLHttpRequest object [XMLHttpRequest].

One notable omission in above definition is what to return if none of the above match. For example, a quick test with fetch() shows that Chrome returns an empty string, while Firefox returns "other" - @toddreifsteck can you try it on Edge?

I think the minimum the need to do here is agree on a fallback. It may also not be a bad idea to add a clause for Fetch.. report "fetch"? Outside of that, I propose we keep the definition as is for L2 as we already have three shipping implementations, and revisit it in L3 - see #8.

@igrigorik
Copy link
Member

@toddreifsteck @nolanlawson trying to test this on Edge.. but I'm not seeing any fetch-initiated requests in the perf timeline at all. Is this a bug, or am I doing something silly?

@toddreifsteck
Copy link
Member

@igrigorik Bug in Edge 14. Fix is understood and will be shipped to Insider builds of Edge 15 in ~2-4 weeks.

@igrigorik
Copy link
Member

@toddreifsteck gotcha, thanks. Do you know what you guys set the initiatorType value to for fetch-initiated requests?

@toddreifsteck
Copy link
Member

We plan to use 'fetch' for initatorType for fetch and mostly like 'beacon' or 'sendBeacon' (depending on other browser's implementation) for sendBeacon.

@igrigorik
Copy link
Member

Resolved via #80, closing.

@MasonM
Copy link

MasonM commented Jun 22, 2021

I stumbled on this issue while trying to figure out what initiatorType means, since the current version version of the spec doesn't define what it means or what the possible values are. The changes in #80 have what was I was looking for, but that was reverted in #261. Was that information moved somewhere else? The latter PR talks about the fetch spec, but that spec doesn't define initiatorType either.

edit: I went ahead and entered a separate issue for this: #276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants