html icon indicating copy to clipboard operation
html copied to clipboard

Allow "style" and "json" in `as` attribute for `modulepreload`

Open KurtCattiSchmidt opened this issue 2 weeks ago • 7 comments

Updates the definition of modulepreload to support as="style" and as="json" for preloading style and JSON module scripts respectively.

Fixes #10233

(See WHATWG Working Mode: Changes for more details.)


/acknowledgements.html ( diff ) /indices.html ( diff ) /links.html ( diff ) /semantics.html ( diff )

KurtCattiSchmidt avatar Dec 02 '25 19:12 KurtCattiSchmidt

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.

KurtCattiSchmidt avatar Dec 05 '25 22:12 KurtCattiSchmidt

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.

annevk avatar Dec 08 '25 07:12 annevk

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.

KurtCattiSchmidt avatar Dec 08 '25 17:12 KurtCattiSchmidt

Latest push handles removing "json" for "preload". I also added the implementation bugs. I'll work on tests next.

KurtCattiSchmidt avatar Dec 08 '25 21:12 KurtCattiSchmidt

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?

KurtCattiSchmidt avatar Dec 09 '25 22:12 KurtCattiSchmidt

Note that the set of module types might be expanding - there's active proposals for text and bytes imports from JS.

bakkot avatar Dec 11 '25 21:12 bakkot

@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?

KurtCattiSchmidt avatar Dec 12 '25 01:12 KurtCattiSchmidt