This module aims to utilize Google Closure Compiler API/application to optimize your cached JavaScript files.

More info about the application/service:
http://code.google.com/closure/compiler/

Closure Compiler module looks at the cached JavaScript folder (sites/default/files/js) and processes files on cron run. It basically 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.

Project Information

Downloads