Last updated April 30, 2010. Created on April 30, 2010.
Edited by mehmeta. Log in to edit this page.

Closure Compiler is a tool from Google to optimize JavaScript code. It offers varying degrees of optimization, from merely stripping whitespace to parsing and analyzing your code, renaming your variable and function names to minimize code size. Closure Compiler module utilizes the API/application to process cached Drupal JavaScript on cron run.

Features

The module supports 3 different modes:

1) Compile locally via Java based compiler
2) Send JavaScript file contents to the API
3) Send JavaScript file paths to the API (Requires your site to be publicly accessible by Google)

First mode requires Java 6+ (http://www.java.com/en/download/) to be installed, compiler.jar file (http://closure-compiler.googlecode.com/files/compiler-latest.zip) present in the module directory and PHP shell_exec function to be executable in your environment without issues. If running the module under IIS, you might need to give read and execute permissions on C:\Windows\System32\cmd.exe to the IUSR_machine_name user. If your environment fails to pass the checks at any time, the module sets the preferred method to the 2nd mode. This mode reads the contents of the JavaScript file, sends them to the actual API, parses the response and replaces the compiled code with the original. If set to use the 3rd mode, or the length of the JavaScript file is over 200K under 2nd mode, the module sends the public path of the file to the API instead of file content and processes the response.

Here's a good reference link describing API methods: http://code.google.com/closure/compiler/docs/api-tutorial1.html

Please note that ADVANCED_OPTIMIZATIONS compilation level tends to be very unstable and breaks Drupal JavaScript most of the time.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.