-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Experimental: JS compression via Closure Compiler #20967
base: 5.x-dev
Are you sure you want to change the base?
Experimental: JS compression via Closure Compiler #20967
Conversation
``` var i = 0; for (i; i < object.length; i++) {} ``` becomes ``` var i; for (i = 0; i < object.length; i++) {} ``` Alternative (unreadable): ``` var i = 0; for (; i < object.length; i++) {} ```
…y_Client` and `piwik_track` undeclared
…mpiler This disables type warnings: `JSC_UNRECOGNIZED_TYPE_ERROR`, `JSC_TYPE_MISMATCH`, `JSC_WRONG_ARGUMENT_COUNT` and more.
…on for `piwik.js`
…for `piwik.js` + Copy all functions that begin with `this.nameOfFunction` from `function Tracker()` in `piwik.js`. Exclude functions inside `/*<DEBUG>*/ … /*</DEBUG>*/`-markers. + Rename inside `piwik.externs.js` via find `^this\.` and replace by `Tracker.` + Empty method bodies inside `piwik.externs.js` via find `\{(\n .+|\n)+\n\};` and replace by `{};`
…for `piwik.js` - fix `Tracker.optUserOut`
…o exclude them from Closure Compiler munging
603676d
to
542bd46
Compare
Thanks for this analysis and contribution @rr-it, it's much appreciated 👍 We'll review this PR and schedule some testing. A ~20% decrease in tracking code size sounds great, even if only a few kilobyte, it can soon add up to a useful traffic reduction when serving many millions of requests per month. |
…ct in quotes to exclude them from Closure Compiler munging
Some common JS names defined in the default Closure Compiler `externs` are not munged e.g.: location, name, target, type, href, enabled, timeout, interval When renamed by prepending with an underscore they get correctly munged.
Some common JS names defined in the default Closure Compiler `externs` are not munged: find, push, trim When renamed the functions and calls get correctly munged.
…definition for `piwik.js`
If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'. |
If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'. |
Description:
Experimental: This introduces JS compression of
piwik.js
viaClosure Compiler
.See #20964
Review