Problem
assets.PreloadHTML promises to load resources efficiently and says recognized non-JavaScript/CSS resources are emitted as preload tags. For generic recognized MIME types it emits rel="preload" and type, but no as destination:
html, _ := assets.PreloadHTML(&url.URL{Path: "module.wasm"})
fmt.Print(html)
Output:
<link rel="preload" href="module.wasm" type="application/wasm">
The HTML preload algorithm derives its request destination from as and stops when the destination is absent or invalid. The type attribute does not replace it, so this tag does not perform the promised preload.
This is an optimization failure only: it does not prevent application code from fetching or instantiating the WASM separately.
Proposed fix
Do not emit destination-less preload links. For application/wasm intended for fetch, emit as="fetch" with matching CORS/credentials metadata, normally crossorigin. Map other supported MIME types to valid destinations, or narrow the documented supported resource classes when their consumer cannot be inferred.
Acceptance criteria
Problem
assets.PreloadHTMLpromises to load resources efficiently and says recognized non-JavaScript/CSS resources are emitted as preload tags. For generic recognized MIME types it emitsrel="preload"andtype, but noasdestination:Output:
The HTML preload algorithm derives its request destination from
asand stops when the destination is absent or invalid. Thetypeattribute does not replace it, so this tag does not perform the promised preload.This is an optimization failure only: it does not prevent application code from fetching or instantiating the WASM separately.
Proposed fix
Do not emit destination-less preload links. For
application/wasmintended forfetch, emitas="fetch"with matching CORS/credentials metadata, normallycrossorigin. Map other supported MIME types to valid destinations, or narrow the documented supported resource classes when their consumer cannot be inferred.Acceptance criteria
as="fetch"preload with matching CORS mode, or is explicitly outside a narrowed documented domain.