whatwg / fetch

Fetch Standard
https://fetch.spec.whatwg.org/
Other
2.1k stars 325 forks source link

Should destination of prefetch/prerender be set? #1252

Open mfalken opened 3 years ago

mfalken commented 3 years ago

Currently prefetch/prerender use the empty string as the destination, as documented at the note at https://fetch.spec.whatwg.org/#concept-request-destination.

Is there any benefit known to doing so, or would it be better for these features to set a destination?

There does seem to be an as attribute on <link rel>: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as. So it could make sense for, e.g., <link rel=preload as=audio> to have destination "audio" and "initiator" prefetch.

And, e.g., <link rel=prerender> or the newly proposed speculationrules could result in initiator "prerender" and destination "document".

Related is the discussion at https://github.com/w3c/resource-hints/issues/74

annevk commented 3 years ago

Did you mean to write <link rel=prefetch> above? For preload we indeed cannot do this because of that. It seems that prefetch could maybe make use of that functionality as well, though someone would have to work through what a mismatch in CSP would mean in that case.