Problem
assets.PreloadHTML emits font URLs without a CORS setting:
html, _ := assets.PreloadHTML(&url.URL{Path: "font.woff2"})
fmt.Print(html)
Output:
<link rel="preload" href="font.woff2" as="font" type="font/woff2">
Without crossorigin, the preload uses the no-CORS state. CSS @font-face fetching uses anonymous CORS mode, while a preload key includes request destination, mode, and credentials. The CSS font consumer therefore cannot consume this preload entry.
See the HTML CORS settings, preload algorithm, and CSS font fetching requirements.
The font still loads normally. The impact is a lost preload optimization and a possible redundant request or transfer, not broken rendering or a guaranteed double download.
Proposed fix
Add an anonymous CORS setting—crossorigin or crossorigin="anonymous"—to generated font preload links.
Acceptance criteria
Problem
assets.PreloadHTMLemits font URLs without a CORS setting:Output:
Without
crossorigin, the preload uses the no-CORS state. CSS@font-facefetching uses anonymous CORS mode, while a preload key includes request destination, mode, and credentials. The CSS font consumer therefore cannot consume this preload entry.See the HTML CORS settings, preload algorithm, and CSS font fetching requirements.
The font still loads normally. The impact is a lost preload optimization and a possible redundant request or transfer, not broken rendering or a guaranteed double download.
Proposed fix
Add an anonymous CORS setting—
crossoriginorcrossorigin="anonymous"—to generated font preload links.Acceptance criteria
as="font", their MIMEtype, and anonymouscrossorigin.font/*MIME extension.