Compressing css and js files with yuicompressor-maven-plugin

Posted by – October 13, 2008

Today I started to be worried about the size of css and js files used by my current project, so I searched for some maven plugins that can do some compression on these resources for me, hopefully I found a nice one called yuicompressor-maven-plugin.

This plugin allows to compress both css and js files, you can compress all of js files into one big file and you can do the same for css files, you can also specify which files should be added as well ignored on compression step.

The following configuration worked very well for me:

[code lang="xml"]

druidtarget

net.sf.alchim
yuicompressor-maven-plugin
0.7.1



compress




false

[/code]

Now just run a maven build and the plugin will find and compress all css and js files inside target/main/webapp for you, your compressed files will have “-min.js” as filename extension. Don’t forget change the links on your pages pointing to these compressed versions.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>