Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use maintained JS minifier #15412

Open
Findus23 opened this issue Jan 17, 2020 · 3 comments
Open

Use maintained JS minifier #15412

Findus23 opened this issue Jan 17, 2020 · 3 comments
Labels
c: Tracking For issues related to getting tracking data into Matomo. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. Technical debt Issues the will help to reduce technical debt

Comments

@Findus23
Copy link
Member

related to #12774
also related to #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,

@Findus23 Findus23 added this to the 4.0.0 milestone Jan 17, 2020
@tsteur
Copy link
Member

tsteur commented Jan 20, 2020

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 Findus23 modified the milestones: 4.0.0, 4.1.0 Jan 20, 2020
@Findus23 Findus23 added the Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. label Apr 20, 2020
@Findus23
Copy link
Member Author

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:

  • file size is very similar (52k instead of 58k and 17k instead of 19k gzipped), which is to be expected as there isn't much more to optimize without removing things.
  • it is probably easier to write a tiny .js file to call instead of using the cli as then one can specify a regex to keep important comments like pluginTrackerHook
  • it supports sourceMaps, so one could debug tracking in production as the browser developer tools can reverse the minification with it
  • the current minifier removes the "use strict" line, which might have had weird concequences.
  • I did not have time yet to test the output, but it should work fine.

@mattab mattab modified the milestones: 4.1.0, 4.2.0 Dec 21, 2020
@mattab mattab modified the milestones: 4.2.0, 4.3.0 Feb 22, 2021
@mattab mattab modified the milestones: 4.3.0, 4.4.0 May 26, 2021
@tsteur tsteur modified the milestones: 4.4.0, 4.7.0 Jul 22, 2021
@sgiehl sgiehl added the Technical debt Issues the will help to reduce technical debt label Aug 28, 2023
@mattab
Copy link
Member

mattab commented Dec 11, 2023

fyi @rr-it Opened a PR and an issue in #20964 to suggest a new compiler 🙌

@mattab mattab added the c: Tracking For issues related to getting tracking data into Matomo. label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Tracking For issues related to getting tracking data into Matomo. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. Technical debt Issues the will help to reduce technical debt
Projects
None yet
Development

No branches or pull requests

4 participants