Experimental: JS compression via Closure Compiler#20967
Draft
rr-it wants to merge 24 commits intomatomo-org:5.x-devfrom
Draft
Experimental: JS compression via Closure Compiler#20967rr-it wants to merge 24 commits intomatomo-org:5.x-devfrom
rr-it wants to merge 24 commits intomatomo-org:5.x-devfrom
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
Contributor
|
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`
Contributor
|
If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'. |
Contributor
|
If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Experimental: This introduces JS compression of
piwik.jsviaClosure Compiler.See #20964
Review