Skip to content

Is a general Script: header a good idea? #8321

Closed
@domenic

Description

@domenic

Hi HTML community,

Over in WICG/nav-speculation, we're looking to extend <script type=speculationrules> with a header-based version, based on feedback from framework developers that it's easier to inject speculation rules at the HTTP level than the HTML level. (Somewhat surprising, I know!)

I think we have two main options:

  1. A speculation-rules specific header. Example:

    Speculation-Rules: "/speculation-rules.json"
  2. A header which allows you to do any "data-like" <script> type, such as speculationrules, importmap, or webbundle. This use of <script> is increasingly common, as due to how HTML parsing works it's one of the few ways to shove in arbitrary data. And it's believable many of these cases would benefit from a HTTP header delivery system, in the same way we've heard speculationrules would.

    Example:

    Script: "/speculation-rules.json";type="speculationrules", "/import-map.json";type="importmap"

(We could even extend (2) to allow type="text/javascript", causing script execution, if we were feeling ambitious. But that opens up a big bag of worms, so let's set that aside for now.)

For right now, I just want to get a sense of the community's feelings on (1) vs. (2). (1) is probably the path of least resistance, but it would be kind of lame if we went that route, and then a year later introduced an Import-Map: header, and a Web-Bundle: header, and so on. Or if there's been latent demand for JavaScript execution via HTTP headers for some time, which would point toward the more-expanded version of (2).

So if people think that (2) is potentially interesting, please let me know as soon as possible!

Appendix: why not `Link:`?

Although none of the data-like <script>s mentioned currently support external versions, we hope for them to do so using <script src=""> in the future. E.g.

<script type="importmap" src="/import-map.json"></script>

Given this, it would be really weird if the header was spelled Link: </import-map.json>; rel="importmap", but the HTML version was spelled like the above. So I think reusing Link would lead to a bad place.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions