New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preloading hashed, static assets with rel="preload" #1508
Comments
Hi @mixn Normally you don't have to add yourself the Does it perform the (Please mention me so I can keep track of this issue). |
@mixn, can you try this:
module.exports = {
render: {
bundleRenderer: {
shouldPreload: (file, type) => {
return ['script', 'style', 'font'].includes(type)
}
}
}
} More informations on https://ssr.vuejs.org/en/api.html#shouldpreload |
Thank you for your quick response, @Atinux, really appreciate it! 💯 Nuxt does
to the If I don’t add anything to With
in place, the font is still not
plus the code suggested above, the font gets loaded twice. Hope I am not missing anything. And thank you for your feedback! 👍 |
@mixn do you have a repo where I can try your implementation? |
@Atinux I’ve added you as a collaborator and pushed the relevant stuff on a separate branch ( |
Can you add @pi0 as well please? |
@mixn After some investigations with @Atinux , we have finally found the problem! It was with webpack scope hoisting which is not working well with server-renderer (SSR and Client bundle assets differ so it couldn't detect non js files for preload). Unit tests also updated to prevent this bug happening with future updates. |
Should be fixed with rc8 now :) @mixn please reopen or mention if the problem still exists. |
@pi0 Upgraded to rc8. By adding
the font still gets loaded twice. By not adding the code above, there is no Hope I’m not missing something. :) |
@mixn Do you add render.shouldPreload too? I'm on mobile but examples/global-css is working. Also there is no need adding meta link. |
@pi0 Yes, I have added
to
no fonts get |
what does this preload script do? I'm really confused.... |
Hello. I've tried shouldPreload option today and it actually works, but with little problem.
|
See #1838 for further discussion and information. |
This bug-report has been fixed by @manniL.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hey there,
I wanted to add a
link
tag withrel="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 thelink
array, where all otherlink
s are: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:
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)
insidestyle
).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!
The text was updated successfully, but these errors were encountered: