Loading fonts causes flickering in dev mode
lostful opened this issue Β· 7 comments
Whenever I reload my page the font flickers
Hey @lostful! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this flickering font issue together!
To fix the issue of font flickering whenever you reload your page, you can use the nuxt-fonts
module to optimize and configure web fonts in your Nuxt app. Here is how you can set it up in your .nuxtrc
file:
typescript.tsConfig.compilerOptions.noUncheckedIndexedAccess=true
modules[]=nuxt-fonts-devtools
This configuration will help in optimizing the fonts and reducing the flickering issue [1].
Is this only in development?
Would you be able to provide a reproduction? π
More info
Why do I need to provide a reproduction?
Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.
What will happen?
If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.
If needs reproduction
labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.
How can I create a reproduction?
We have a template for starting with a minimal reproduction:
π https://stackblitz.com/github/nuxt/fonts/tree/main/example
A public GitHub repository is also perfect. π
Please ensure that the reproduction is as minimal as possible. See more details in our guide.
You might also find these other articles interesting and/or helpful:
Is this only in development?
Ah yes, this is only in development. Is that intended?
Not intended, but I did observe it previously. Need to investigate, so letβs leave it open.
same here
i have the font in my css like this
@font-face {
font-family: 'Quicksand';
src: url('/fonts/quicksand/Quicksand-VariableFont_wght.ttf') format('TrueType');
font-weight: normal;
font-style: normal;
font-display: swap;
}
and the actual file is in the public directory public/fonts
maybe I should do it differently?
This looks like an upstream vite bug to me - likely caused by the fact that:
<link rel="stylesheet" href="/_nuxt/__uno.css">
returns a JS module and not CSS.