Skip to content

JavaScript minification

chuckdumont edited this page Oct 18, 2012 · 5 revisions

The Aggregator uses the Google Closure Compiler to perform JavaScript minification of .js modules, including:

  • Removal of comments, white-space and unneeded block delimiters
  • Renaming of local and function variables to use shorter names
  • Dead code removal
  • Code re-organization (e.g. changing if-then-else blocks to use tertiary operator).

The Aggregator uses the Closure Compiler's simple optimization level for JavaScript optimizations. You can optionally specify an optimization level of whitespace only for debugging by setting optimize="whitespace" in the loader extension config. This will cause the compiler to remove comments and whitespace, but not rename any variables. Setting the optimization level "none" removes all optimization, by-passing the compiler, but this has the effect of disabling code trimming using has.js feature detection, as well as require list expansion, since both of these features depend on functionality provided by the compiler.