CodePark/ questions / Loading scripts & resources
START PRACTICINGPRACTICE
Frontend question · Browser & web performance › Loading scripts & resources

You preload a self-hosted font, but DevTools shows it downloaded twice. What is the likely cause?

<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2">
The preload is missing the crossorigin attribute

The browser always fetches fonts in CORS mode, even from the same origin. CORS is the browser's cross-origin permission check. So a font preload needs the crossorigin attribute. Without it, the preloaded response does not match the real font request, and the browser downloads the font again.

"Fonts cannot be preloaded" is the tempting wrong answer. Fonts can be preloaded with
as="font", and this is a common use. as="style" is wrong, because that is for stylesheets. Removing the type attribute doesn't fix the mismatch.