Jawr 2.0: Bundles and Minifies, now for Grails and Facelets
Jawr is configured by adding a servlet to our application and creating a simple .properties file to configure the way components are to be bundled. CSS files can also benefit from bundling and compression. Once configured, a tag library (of either the JSP, Grails or Facelets kind) is used to reference the bundles previously defined.
These tags will work differently in development and production modes (which are set by a flag in the properties file). When in development mode, links to the separate, uncompressed modules are generated so that we can debug them using, say, Firebug. Each links gets a random parameter added to the URL so that upon every refresh of our page the browser is force to reload the script. On the other hand, in production mode links to the bundled, minified and compressed version of the scripts are generated. There is no need to change anything in the pages for this to happen, only a flag switch in the properties file is needed.
Other interesting features are, aside from the aforementioned Facelets and Grails integration, are the ability to define custom postprocessors to change dynamically the contents of bundled scripts, the ability to define global bundles that are always imported into pages automatically, defining bundles which are included within a defined conditional comment for MSIE, obfuscating the scripts, etc...
Jawr has an Apache 2.0 license, and can be configured to use JSmin or the YUI Compressor under the hood, both with a BSD style license. You can find all about it at https:\\jawr.dev.java.net
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)