-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Compress matomo.js via Closure Compiler instead of YUI Compressor #20964
Copy link
Copy link
Open
Labels
EnhancementFor new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.Technical debtIssues the will help to reduce technical debtIssues the will help to reduce technical debtc: PerformanceFor when we could improve the performance / speed of Matomo.For when we could improve the performance / speed of Matomo.c: TrackingFor issues related to getting tracking data into Matomo.For issues related to getting tracking data into Matomo.
Milestone
Metadata
Metadata
Assignees
Labels
EnhancementFor new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.Technical debtIssues the will help to reduce technical debtIssues the will help to reduce technical debtc: PerformanceFor when we could improve the performance / speed of Matomo.For when we could improve the performance / speed of Matomo.c: TrackingFor issues related to getting tracking data into Matomo.For issues related to getting tracking data into Matomo.
Summary
The use of Closure Compiler (CC) has some benefits over YUI Compressor (YUI).
Sligtly smaller file size
51.8 KBvs. YUI66.3 KB18.9 KBvs. YUI21.5 KBSligtly better performance of generated JS-code
CC optimises the generated JS-code with multiple performance tweaks:
Error and Warning reports on JS code smells and errors
CC gives feedback on JS code smells and errors. See all the annotations that are suppressable.
CC can enforce
ECMAScript: ECMA-262, edition 3and thereby ensures Browser Compatibility:java -jar closure-compiler-v20230502.jar --language_in ECMASCRIPT3 --language_out ECMASCRIPT3Munging of private object property names
CC also munges object property names.
E.g.
findContentNodesWithinNodeis only used internaly inside the closure function.The call
content.findContentNodesWithinNode(domNode)becomes:a.Bb(z)a.findContentNodesWithinNode(z)Munging of all function names (PRO & CON)
By default CC munges really all function names - and thereby also the public Tracking API names.
The munging of public function names is prevented by an extra JS-file containing an
@externsannotation and the function definitions.externs-definitions must be created and maintained.externs-definitions are created and maintained. Thereby we get a technical approach to define the public API.See Closure Compiler: Externs and Exports
Munging of all property names in data-objects (CON)
CC munges all property names. All call-parameters that must not be changed, must be in proper quotes.
See Closure Compiler: Restrictions for
ADVANCED_OPTIMIZATIONSRelated to