matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.56k stars 2.61k forks source link

Use maintained JS minifier #15412

Open Findus23 opened 4 years ago

Findus23 commented 4 years ago

related to https://github.com/matomo-org/matomo/pull/12774 also related to https://github.com/matomo-org/matomo/issues/5165

The last release for yuicompressor is nearly 7 years old. Especially for a fast moving language like Javascript this means that it was designed for browsers that have little in common with the ones that exist now.

Of course after replacing it with a maintained minifier we need to test if all features still work and that the minifier doesn't use any features that are missing in ancient browsers,

tsteur commented 4 years ago

Of course after replacing it with a maintained minifier we need to test if all features still work and that the minifier doesn't use any features that are missing in ancient browsers,

This might be bit hard?

Just to understand: Is the benefit that it will result in a slightly smaller minified JS basically?

Since this is basically no breaking change for users, I would prefer to move this into the priority backlog or 4.1 or 4.2 for now to keep 4.0 as small as possible (otherwise takes much longer to work on 4.0).

Maybe a quick test be to use some modern minifier, then use the minifier we use, and see how much different the resulting JS file size is to evaluate if it's worth doing or not.

Findus23 commented 4 years ago

I looked into it again and tested UglifyJS3 (https://github.com/mishoo/UglifyJS2) which is the most popular minifier (used by over 4 Million github repos) for ECMAScript 5. (It doesn't support newer JS features, but it will take ages until we can support them in the tracking code anyway, so this should not matter)

uglifyjs  piwik.js -c -m eval --comments -o piwik.ugl.js

Things I noticed:

mattab commented 8 months ago

fyi @rr-it Opened a PR and an issue in https://github.com/matomo-org/matomo/issues/20964 to suggest a new compiler :raised_hands: