Static GitHub Issues

[1508] Preloading hashed, static assets with rel="preload"

prev: Add HMR or automatic server restart for modified serverMiddleware scripts
next: Page still rendered 'live' even for generated pages

Hey there,

I wanted to add a link tag with rel="preload" for two fonts that I am using, so that the priority in which they are loaded is higher (especially when coming from a ServiceWorker, since they are currently prioritized as lowest — which slows down things).

I added this to my nuxt.config.js inside the link array, where all other links are:

{
  rel: 'preload',
  as: 'font',
  crossorigin: 'crossorigin',
  type: 'font/woff2',
  href: 'fonts/ApercuPro.woff2'
}

The problem I am experiencing is that the preloaded font is now being loaded twice, once the hashed version, the other time the raw, original one as can be seen here:

double-font-load

Ideally, only the hashed version of the file should be referenced inside href, just like Nuxt already does this with all other references to that particular file (e.g. url(/_nuxt/fonts/ApercuPro.5398148.woff2) inside style).

Sorry if I am missing something here and thank you for your feedback in advance. :) Been a happy user for a while now. ❤️ Also glad to help in any way, if I can!

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This bug report is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1343">#c1343</a>)</em></sub></div>