Hi. I installed matomo on a shared hosting site and configured it for a day. However, the site on gtmetrix with slower connections (like 3G) shows the matomo tracking script taking over three seconds to load! Hence, I had to delete the installation altogether. Is there a way to speed up the script?
The Matomo tracking script (matomo.js) is just a JS file that is delivered by your webserver (the PHP application doesn’t interfere here at all).
So check your webserver config to see if everything is optimized ideally. Most importantly check if you gzip the outgoing static files. This reduces the size from around 68KB to 23KB.
I am aware, that the matomo.js could be smaller, but in needs to include huge functions to make sure it works in Internet Explorer 7 and older. In Matomo 4 they will be removed making it again much smaller.
If we assume a download speed of 750 Kbps (which Firefox calls “Regular 3G” when testing) this means we get (23 KB)/(750 Kbps)=0.24 seconds download speed. That isn’t amazingly fast (and 3G isn’t fast), but should not slow down your website. With the average website having around 3MB nowadays (and therefore taking 32 seconds to download) Matomo is the least thing that slows anything down (and that is even ignoring the fact that it only starts loading once the website is completly finished and the user can interact with the website)
My website is configured properly. It is on LiteSpeed server with LS cache plugin and brotli activated. But still, your script is slow. Google Analytics takes less than a second to load on the 3G connection compared to Matomo’s 3+ seconds, so there is a need there for your team to optimise the script because most of the developing world is on 3G and even some on 2G. To add, my homepage is just 80kb when cached. My CSS file is below 40kb.So, I still insist the problem is with your script.
https://google-analytics.com/ga.js is 46KB large (17KB gzipped), so only 6KB smaller than matomo.js. So the download time should be nearly the same for both (and with Matomo 4 the difference becomes even smaller). And as you are using brotli, you can compress the matomo.js even down to 20KB.