unplugin-fonts icon indicating copy to clipboard operation
unplugin-fonts copied to clipboard

[Bug]: Console Warning : Resource was preloaded but not used within a few seconds

Open 1Luc1 opened this issue 1 year ago • 4 comments

Demo URL

No response

What happened?

I set up a FontSource like described within the ReadMe. In particularly I used the variable fontsource "@fontsource-variable/source-serif-4": "^5.0.19"

This Warning shows only if the app is build. Within development this warning does not appear.

I don't know if this is related to https://github.com/cssninjaStudio/unplugin-fonts/issues/64 or not; this is why I upvoted/promoted that issue.

vue v3.4.27
vite v5.2.11
unplugin-fonts v1.1.1

Reproduction steps

  1. install unplugin-fonts v1.1.1
  2. install fontsource (e.g. @fontsource-variable/source-serif-4)
  3. setup unplugin-fonts to use fontsource within vite.config.mjs
    Unfonts({
      fontsource: {
        families: ["Source Serif 4 Variable"],
      },
    }),
  1. import unfonts style within main.js import "unfonts.css";

  2. use font somewhere within app

   html {
    font-family: "Source Serif 4 Variable", sans-serif;
  }

Relevant log output

The resource [URL *.eot, *.woff2, *.woff, *.ttf] was
preloaded using link preload but not used within a few seconds from the
window's load event. Please make sure it has an appropriate `as` value and
it is preloaded intentionally.

What browsers are you seeing the problem on?

Firefox, Microsoft Edge, Other

What is your operating system?

Windows, Linux

1Luc1 avatar May 13 '24 08:05 1Luc1

I'm seeing this issue in default Vuetify installation. Haven't change anything related to fonts whatsoever.

Shujee avatar Mar 04 '25 12:03 Shujee

Related to https://github.com/cssninjaStudio/unplugin-fonts/issues/74

segevfiner avatar Mar 17 '25 14:03 segevfiner

Can confirm this is problematic. It should not mark everything as preload and at least give the user the ability to change whether fontsource fonts are preloaded.

douira avatar May 28 '25 18:05 douira

As stated here https://github.com/cssninjaStudio/unplugin-fonts/issues/74#issuecomment-2839262656, a workaround is to add preload: false

UnpluginFonts({
  ...
  custom: {
    ...
    preload: false,
  },
}),

1Luc1 avatar Jun 25 '25 17:06 1Luc1