johannschopplich / nuxt-gtag

🔸 Google Analytics & Ads integration made easy
https://developers.google.com/tag-platform/gtagjs
MIT License
302 stars 9 forks source link

'Reduce unused JavaScript' suggestions? #57

Closed InstantlyMoist closed 8 months ago

InstantlyMoist commented 8 months ago

Environment


Running within Docker

Reproduction

Currently none, installed nuxt-gtag and added to the module

Describe the bug

image

Currently this shows up in lighthouse as 'Unused JavaScript', while the loadingStrategy is set to 'defer', with 'async' we're getting the same issue.

Is there any way to prevent this, as it's pulling our performance score down on mobile. Thanks!

Additional context

No response

Logs

No response

johannschopplich commented 8 months ago

Thanks for the report. Sorry, but there's nothing this library can do, except if you use a cookie banner and let the user opt-in to tracking – then, the gtag.js library is loaded later during the lifecycle of your app.

This Nuxt module merely loads Google's gtag.js library and adds some configuration options. Thus, the Lighthouse issue originates in Google's own library size. The Google crawler waits until all scripts are loaded, that's why defer and async behave the same in your case.

Closing this, due not connected to this module.