Ant task for minifying JS/CSS files using YUI Compressor

Recently, while working on a project, I had the need for minifying a set of Javascript and CSS files. Although the project was in HTML5 with no server side component, I had set up the build process using Apache Ant.

I looked online for an ant library that could accomplish this and came across one that was almost exactly what I was looking for. It could minify JS files using YUI Compressor but lacked a couple of features I required. So, I went through the library’s source code and added the following features

  • Minification option for CSS files
  • Option to delete original source files after minification

Since other people might want to use these additional features, I’ve made the modified library open source on GitHub:

https://github.com/parambirs/ant-yui-compressor

The README file describes the available options and how to use them. There’s also an example folder with a working ant project for JS/CSS minification. My code is based on the yui-compressor-ant-task hosted on google code.