Closure compiler service is deprecated, and will be removed. Please consider running the compiler locally instead.
The Hello World of the Closure Compiler Service API
Create an HTML page
Create a file called
closure_compiler_test.htmland paste in this code:
The form on this page gives you a simple (if contrived) way to invoke the Closure Compiler service API using an HTTP POST request.
Note that the
compilation_levelparameter is set to
WHITESPACE_ONLY, which tells the Closure Compiler service to apply the most basic optimizations to the code. You can set this parameter's value to
ADVANCED_OPTIMIZATIONSto try more advanced levels of optimization. For more information about these compilation levels, see the API Reference.
Open the page in your browser
closure_compiler_test.htmlin your browser. You should see a page that looks like the screenshot below:
Click "Optimize" to submit the code to the Closure Compiler Service API
You should see this resulting code, with comments and whitespace removed:
Now that you've seen the basics of the Closure Compiler service API, you can learn more about how to use and configure it in Communicating with the Closure Compiler Service API.