Tuesday, 7. April 2015
closure-compiler is part of every modern linux distribution. if it’s not installed hit “sudo apt install closure-compiler” in a terminal and press enter 🙂
to minimize your js file you can now write:
closure-compiler --js game.js --js_output_file game.min.js --language_in ES5 --compilation_level SIMPLE_OPTIMIZATIONS
the –language part makes sure that it runs through (in my case) even with some “reserved” names as custom variable names.. (i am using the phaser framework and “static” for example is a common (otherwise not allowed) name for an attribute)
using advanced_optimations instead of simple_optimations would lead to a more obfuscated output but is not working properly if you include several other js files because it’s heavily renaming everything – starting with classes, methods, attributes, etc.