Make PiwikPro java script code smaller?

I am a new PiwikPro Core plan user. I have installed the Piwik java script code on my WordPress websites with the PiwikPro WordPress plugin.

I noticed that the java script code installed by PiwkPro is a lot bigger than the code used by Google Analytics. The Piwik code is around 86KB and the GA code is just around 20KB. Uncompressed the Piwik code is more than 300KB.

Is there any way to make the code smaller in size? For example by disabling options in the Data collection settings?

Thanks for the help!

Best Wishes,
Alwin

Hello @optipiwik, which .js file did you look at when analyzing size?
By default our container code is also responsible for loading Consent Manager and Tag Manager. That’s the file that contains the ID of your site or app from Piwik PRO (example: “74bda40d-ed9d-40c8-ac93-99d58da82a95.js”).

If considering just the main Analytics library (our JavaScript Tracking Client called ppms.js or ppas.js) loaded standalone or inside of the Tag Manager, the code is indeed a bit bigger than GA’s analytics library, but that doesn’t affect website’s overall performance. You can verify that by running tools like Lighthouse.

However, we understand that optimizing sizes of assets like JS libraries is important. Because of that, we are planning to reduce the size of our Analytics library in the near future. I’ll update this thread once we can share more details.

Thank you for your help Piotrek!

Trying to understand how PiwikPro code works:

I see 3 connections in my GTmetrix report:

  1. https://option-webdesign.containers.piwik.pro/0ac0d197-f254-48d9-9ffa-67ba0e222f8d.js
    (60,6 KB compressed / 224KB uncompressed)

  2. https://option-webdesign.containers.piwik.pro/ppms.js
    (26,6 KB / 79,3KB)

  3. https://option-webdesign.piwik.pro/ppms.php?action_name=Experiment%20Krewerd%20|%20Aardbevingsdorp%20neemt%20heft%20in%20eigen%20handen&idsite=0ac0d197-f254-48d9-9ffa-67ba0e222f8d&rec=1&r=691412&h=2&m=37&s=31&url=https%3A%2F%2Fwww.experimentkrewerd.nl%2F&_idts=1665135452&_idvc=1&_idn=1&_viewts=1665135452&send_image=0&ts_n=jstc_tm&ts_v=2.8.3&cookie=1&res=1367x864&gt_ms=22&pv_id=E3PQEy

(0 KB/ 0KB)

Now some questions:

  • Do I need all three of them? What is the 3th one with 0KB? Seems like an empty URL?
  • Will the code be smaller if I add the code manually and do not use the WordPress plugin?
  • Can I deactivate the Tag Manager to make the code smaller?

Thanks for your help :slight_smile:
Alwin

You can get rid of the first one, but it means basically disabling the Tag Manager module. Requires also some custom code to be added. No. 3 is the actual request that transfers data to the analytics backend, so it’s a must have. Its size is 0 because all the data is passed via GET params or headers.

Thank you for your help kuba!