Google Closure Compiler for Javascript

The Closure Compiler by Google reduces the size of Javascript files by reducing the length of variable and function names, removing whitespace and comments, and writing syntactically shorter Javascript code. The compiler is a stand-alone file called compiler.jar It can be found in the statics/js/closure/closure/bin/build/

directory of the cherrypy of cherrypy-devel servers.

Running the Closure Compiler on non-Closure Javascript

The compiler.jar can be ran on any non-Closure-based Javascript code by entering via command line: java -jar compiler.jar --compilation_level optimization_level --js infile.js --js_output_file outfile.js where optimization_level can be WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, or ADVANCED_OPTIMIZATIONS and infile.js is the name of the input file you wish to compile while outfile.js is the name of the output file you wish to compile.

Running the Closure Compiler on Closure Javascript

To run the closure compiler on Google Closure-based Javascript code, it is necessary to run:

closure/closure/bin/build/ --root=closure/ --name=file_namespace --compiler_jar=closure/closure/bin/build/compiler.jar --output_mode=compiled infile.js > outfile.js

This command assumes that the current working directory is static/js/. file_namespace is the namespace provided by the Javascript file to be compiled. infile.js is the name of the Javascript file to be compiled. outfile.js is the name of the compiled output Javascript file.

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2016-01-20 - ThomasCartwright
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback