• Repository : http://oss.sonatype.org/content/groups/public (since version 1.0, available on central repository)
  • GroupId : net.alchim31.maven (changed since 0.9)
  • ArtifactId : yuicompressor-maven-plugin
  • ArtifactId : 1.5.1




Compress (Minify + Ofuscate) Javascript files and CSS files using YUI Compressor from Julien Lecomte. Because Javascript compression could need time and resource, and to avoid repetitive (stupid) resources consumming at runtime, this plugin do compression of static files at compile time .

  • Compression is applied on webapp dir (src/main/webapp) and on resources (usefull for framework like Wicket where js and css could be in jar).
  • Compressed Files are renamed with a suffix (default "-min"), so both version are available (compressed and original) in the targeting application, but if you don't want to keep original and want to overwrite it set option 'nosuffix' to 'true'.
  • there are other options see details.


Check Javascript file with jslint

Sample Output

A sample output extract from my working project :

[INFO] [yuicompressor:compress]
[INFO] uni-form-generic.css (4902b) -> uni-form-generic-min.css (1625b)[33%]
[INFO] uni-form.css (8431b) -> uni-form-min.css (3435b)[40%]
[WARNING] .../src/main/webapp/static/uni-form/js/highlighter.js:line -1:column -1:Found an undeclared symbol: i
        Highlighter.settings.field_class);for(i ---> = <--- 0;i<fields.length;i
[INFO] highlighter.js (3213b) -> highlighter-min.js (1625b)[50%]
[WARNING] .../src/main/webapp/static/uni-form/js/uni-form.jquery.js:line -1:column -1:Found an undeclared symbol: $
        ;});});};$ ---> ( <--- document).ready(function (){
[INFO] uni-form.jquery.js (1261b) -> uni-form.jquery-min.js (674b)[53%]
[INFO] style.css (11620b) -> style-min.css (8474b)[72%]
[INFO] buttons.css (2513b) -> buttons-min.css (1227b)[48%]
[INFO] grid.css (5012b) -> grid-min.css (2003b)[39%]
[INFO] reset.css (1164b) -> reset-min.css (642b)[55%]
[INFO] typography.css (5136b) -> typography-min.css (1800b)[35%]
[INFO] print.css (1568b) -> print-min.css (631b)[40%]
[INFO] screen.css (1035b) -> screen-min.css (103b)[9%]
[INFO] navbar.css (653b) -> navbar-min.css (460b)[70%]
[INFO] total input (46508b) -> output (22699b)[48%]
[INFO] nb warnings: 2, nb errors: 0
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Aug 28 23:40:57 CEST 2007
[INFO] Final Memory: 12M/21M
[INFO] ------------------------------------------------------------------------