Search code examples
javajavascriptjakarta-eebuild-processgoogle-closure

JavaScript + css handling - Closure Tools / any other tools?


We do not have a lot of experience in Javascript/CSS world as we do primarily Java EE projects (backends). We usually have webapp/resource directory where is all the JS+CSS content and that`s it.

It would be great to have better management of those JS+CSS resources, minifier, resource versioning, maybe obfuscator. I am really curious if someone is using Google Closure tools or any other useful tools which would improved our project. I am not sure if Grunt (build tool for JS projects) could help us in any way. We are using mostly bootstrap + jquery but we do plan to move on and try new 'cool' JS frameworks as Angular or Node.js.

Can you share a bit of your experience on this field ? How do you handle JS+CSS resources in your Java project ?


Solution

  • Google Closure and the Closure Compiler could be a good solution for your JavaScript.

    The management and versioning of your JavaScript, Cascading Style Sheets, and media content should be done in some sort version control. Outside of that, the obfuscation, minification, and optimization of your JavaScript could be done with the Closure Compiler doing ADVANCED_OPTIMIZATIONS.

    In practice, you develop your JavaScript files in their "raw" form, and then do end user testing with the JavaScript ran through the Closure Compiler. The compilation is generally done automatically somewhere in your deployment processes to staging or production environments, but you will probably want the compiler available for your developers to do locally.

    Note: The Closure Compiler only optimizes your JavaScript, not your Cascading Style Sheets. If you want to minify that as well, you need another tool.