Allow "style" and "json" in `as` attribute for `modulepreload`
Updates the definition of modulepreload to support as="style" and as="json" for preloading style and JSON module scripts respectively.
Fixes #10233
- [X] At least two implementers are interested (and none opposed):
- Chromium
- WebKit
- [X] Tests are written and can be reviewed and commented upon at:
- https://github.com/web-platform-tests/wpt/pull/56617
- [X] Implementation bugs are filed:
- Chromium: https://issues.chromium.org/issues/466888680
- Gecko: https://bugzilla.mozilla.org/show_bug.cgi?id=2004751
- WebKit: https://bugs.webkit.org/show_bug.cgi?id=303761
- Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
- Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …
- [X] Corresponding HTML AAM & ARIA in HTML issues & PRs: N/A, as this feature is unrelated to accessibility.
- [X] MDN issue is filed: PR here: https://github.com/mdn/content/pull/42333
- [X] The top of this comment includes a clear commit message to use.
(See WHATWG Working Mode: Changes for more details.)
/acknowledgements.html ( diff ) /indices.html ( diff ) /links.html ( diff ) /semantics.html ( diff )
Should we also disallow "
json" for<link rel=preload>?
You're right, "json" doesn't really make sense in preload if it's supported for modulepreload. I think this should be handled separately though, because WebKit recently added support for <link rel=preload as=json>, and we can have both for some window of time.
Filed https://github.com/whatwg/html/issues/11995 to track and discuss separately.
I'd rather tackle them together as I have a feeling #11995 will not be addressed anytime soon otherwise. And it would be good to have that infrastructure in place as we add more types, such as text and bytes.
I assumed there would be some window of overlap between the new and deprecated version, which is why I filed a separate bug. But if we can do them in one shot that's great. This feature is a little different in that it's not directly observable, so it does seem safe to just deprecate.
I'll update this PR to remove <link type="preload" as="json"> today.
@rniwa - you recently added support for <link type="preload" as="json"> in WebKit so your input here is appreciated.
Latest push handles removing "json" for "preload". I also added the implementation bugs. I'll work on tests next.
Tests and MDN PR's have been are added, so the only missing part in compliance above is "two implementors are interested". @rniwa - can you give a WebKit position in https://bugs.webkit.org/show_bug.cgi?id=303761?
Note that the set of module types might be expanding - there's active proposals for text and bytes imports from JS.
@annevk - you mentioned a missing conformance section for the as attribute, but I don't see an existing section for it, just https://html.spec.whatwg.org/#attr-link-as. Is this something I should add? Or is the table I edited in this PR under https://html.spec.whatwg.org/#attributes-3 sufficient?