Compacting JS and CSS resources with Granule taglib


Granule is a compressor tool to unify all CSS and JS resources on Java Web app. It supports many compression techniques like cssfastmin, jsfastmin, combine only and closure-compile.

Your use is so simple, first download from repository (at Github have many forks with bugs fix, but them aren’t synchronized with main version ¬¬):

On your application, put granule.jar in ‘WEB-INF/lib’ folder and put in WEB-INF folder.

On all your pages, you’ll declare the import instruction below:

Below, an example of Granule usage in your JSP pages:

Warning! Sometimes, on first request, the combined.js and/or combined.css can throws “not found” and not loading on client side, to fix this, you can use this ugly scriplet to force full path for combined CSS/JS files: