Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Removing Unused Javascript (gtag.js)

  • #9683
    Avatar photo[anonymous]

    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 photo[anonymous]

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

    #9701
    Avatar photo[anonymous]

    asasasassaaaaasas

    #9710
    Avatar photo[anonymous]

    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 photo[anonymous]

    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.