nuxt-webfontloader icon indicating copy to clipboard operation
nuxt-webfontloader copied to clipboard

How to add rel=preload to improve lighthouse performance score

Open hjujah opened this issue 5 years ago • 4 comments

I keep having this error in the lighthouse audits and I can't find a workaround for it: Consider using to prioritize fetching resources that are currently requested later in page load.

Its dramatically decreasing the performance score, so i am wondering if there is a way to add the preload attribute somehow?

Here is what I have in my nuxt config atm:

webfontloader: {
      custom: {
          families: ['GarnettMedium-Regular', 'Staff-Medium', 'Staff-Regular'],
          urls: ['/fonts.css']
      }
 }

Any help would be highly appreciated! Thanks!

hjujah avatar Aug 18 '20 23:08 hjujah

Any updates on this? Would be great to get any answer since the client is pushing us to fix that issue... :(

hjujah avatar Aug 29 '20 11:08 hjujah

+1 CC: @manniL @Developmint

mahapo avatar Oct 06 '20 15:10 mahapo

I fixed the issue with adding the link manually to "nuxt.config.js".

  head: {
	...,
    link: [
      {
        rel: "preload",
        as: "style",
        href: "/fonts.css",
      },
    ],
  },

mahapo avatar Oct 06 '20 17:10 mahapo

@mahapo This method doesn't load fonts for me. I am using Google fonts link on "nuxt": "^2.14.0".

m-haziq avatar Jun 23 '21 12:06 m-haziq