Astro Info
Astro v6.0.2
Vite v7.3.1
Node v24.13.0
System macOS (arm64)
Package Manager npm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
using <Font preload /> can produce a large number of <link rel="preload"> tags.
https://myakura.github.io/test--astro-v6-font-preloading/ (repo)
steps to observe:
- open index.html and check the
<head> in DevTools — there are number of <link rel="preload"> tags
- open en.html — this page has only Latin content, but all preloads for the other pages are there, including Japanese unicode-range blocks the page will never render
- open ja.html — Noto Sans JP is a variable font on Google Fonts, but Astro requests separate files for each weight (400 and 700), roughly doubling the number of fetches
What's the expected result?
the current implementation appears to preload all font files unconditionally. so rather than improving performance, this likely makes it worse.
the problem is especially huge for languages like Japanese, Chinese, or other scripts that have many number of characters.
in an ideal situation
- preload links should only be the ones actually cover characters used on the page
- when a variable font is available (like Noto Sans JP or many others on Google Fonts), it should use as a variable font rather than splitting into separate per-weight files
- there should be the cap of preload links. this should help if the number of preloads would still be many
i don't think that would be trivial, though... could the build emit a console warning when the number of generated preload links that is above a threshold? that would at least make it visible to developers that is not a great situation for performance.
Link to Minimal Reproducible Example
https://myakura.github.io/test--astro-v6-font-preloading/
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
using
<Font preload />can produce a large number of<link rel="preload">tags.https://myakura.github.io/test--astro-v6-font-preloading/ (repo)
steps to observe:
<head>in DevTools — there are number of<link rel="preload">tagsWhat's the expected result?
the current implementation appears to preload all font files unconditionally. so rather than improving performance, this likely makes it worse.
the problem is especially huge for languages like Japanese, Chinese, or other scripts that have many number of characters.
in an ideal situation
i don't think that would be trivial, though... could the build emit a console warning when the number of generated preload links that is above a threshold? that would at least make it visible to developers that is not a great situation for performance.
Link to Minimal Reproducible Example
https://myakura.github.io/test--astro-v6-font-preloading/
Participation