Sign in

Removing Unused Javascript (gtag.js)

  • This topic has 4 replies, 3 voices, and was last updated 2 months, 1 week ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9683
    Avatar photoTakumiFujiwara

    Hello, so I’m pretty new to this platform and I like it very much but just want to know if there’s a possibility to remove unused javascripts? I have this problem when I use the PageSpeed Insight (pagespeed.web.dev) to monitor my website performance in various aspects and upon integrating the Google Analytics on my website, the PageSpeed Insights had detected that I have an unused javascript that referring to the gtag.js. I know it needs that javascript for the Google Analytics to work but seems like PageSpeed Insights detected it as unusable.

    Really appreciate if you could help me with this. Thanks

    #9684
    Avatar photoTakumiFujiwara

    This is a sample of message I was getting from PageSpeed Insight

    #9701
    Avatar photoTakumiFujiwara

    asasasassaaaaasas

    #9710
    Avatar photoitips3727

    gtag. js is Google’s JavaScript framework that is used to add Google tags directly to web pages. If you opt to no longer use Google Analytics — that is, delete the Google Analytics code from your Publii > Tools & Plugins > Custom HTMl > Head — then I would imagine gtag.js should no longer be used or slow down your PageSpeed Insights calculations = so your scores should rise.

    Maybe one of the tracking plugins from https://marketplace.getpublii.com/plugins/ might be more helpful. Matomo Analytics looks interesting: https://marketplace.getpublii.com/plugins/matomo-analytics/. Though it seems all tracking analytics must have some loading implications.

    #9712
    Avatar photoharold_t

    As I understand it, Google Analytics can be used without Google Tag Manager if you only track page views, link clicks and scroll depth.

    1. Is it possible to use Google Analytics without Google Tag Manager in Publii?

    2. Is it possible to defer loading the Google Tag Manager’s javascript until it’s needed? My thinking is that this would decrease the bytes consumed by network activity when the page loads, resulting in better performance.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.