Search code examples
google-closure-compilergoogle-closure-library

Including HTML Files in Closure Compiler


The Closure Compiler works great on .js files; something I can't figure out however is how to pass .html files to compiler.jar so that all references are preserved. Also, is it possible to pass .html files to the compiler to obfuscate <script>...</script> sections?

Many thanks, Kate.


Solution

  • Closure Compiler can not compile javascript embedded in HTML (https://developers.google.com/closure/compiler/faq#tags)

    As burnttoast11 mentioned, use exporting to preserve javascript object names you need to use in the HTML javascript (https://developers.google.com/closure/compiler/docs/api-tutorial3#export).

    Lastly, the more code you can move out of HTML and into separate Javascript files, the more work closure compiler can do for you.