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

Performance penalisation for missing preconnect attributes

Open dvago opened this issue 5 years ago • 3 comments

Good morning/afternoon.

First of all, thanks for this package

I would like to flag that using the package in production causes a penalisation when auditing via Google Lighthouse (Chrome devtools - audit panel) as the generated font urls are missing the preconnect flag.

Consider adding preconnect or dns-prefetch resource hints to establish early connections to important third-party origins. Learn more.

It would beneficial either have a configuration option to inject this flag or add it straight away during the building.

Thank you in advance for considering this request.

dvago avatar Apr 16 '20 12:04 dvago

   head: {
      link: [
        { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: true },
        { rel: 'dns-prefetch', href: 'https://fonts.gstatic.com', crossorigin: true },
      ],
    },

ram-you avatar May 28 '20 21:05 ram-you

   head: {
      link: [
        { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: true },
        { rel: 'dns-prefetch', href: 'https://fonts.gstatic.com', crossorigin: true },
      ],
    },

I believe you meant:

 head: {
    link: [
      {
        rel: 'preconnect',
        href: 'https://fonts.gstatic.com',
        crossorigin: true
      },
      {
        rel: 'dns-prefetch',
        href: 'https://fonts.googleapis.com/',
        crossorigin: true
      }
    ]
}

As it happens in two stages. P.S Good article about font performance with a lot of explanation: https://www.smashingmagazine.com/2019/06/optimizing-google-fonts-performance/

Albertbol avatar Jul 07 '20 20:07 Albertbol

This one can be used for custom font loading from static or assets folders also with caching headers on firebase.json for firebase hosting? Any recommendations?

LOG-TAG avatar Jul 10 '20 09:07 LOG-TAG