Ant Task to compress JavaScript and CSS using YUICompressor

In the Ant task for combining multiple JavaScript files into one and minifying them using Dojo Shrinksafe entry i built a sample ant task that can be used to combine and minify JavaScript using Dojo ShrinkSafe.

But what if you want to use the YUI Compressor, or you want to combine and minify css, so i built this task for that

<target name="minify" >
<antcall target="minifyjs" />
<antcall target="minifycss" />
<target name="minifyjs" >
<mkdir dir="build/WebContent/js" />
<concat destfile="build/WebContent/js/combined.js">
<fileset dir="WebContent/js" includes="*.js" />
<java fork="true" jar="${yuicompressor.lib.dir}" dir="build/WebContent/js"
<arg value="combined.js" />

<target name="minifycss" >
<mkdir dir="build/WebContent/css" />
<concat destfile="build/WebContent/css/combined.css">
<fileset dir="WebContent/css" includes="*.css" />
<java fork="true" jar="${yuicompressor.lib.dir}" dir="build/WebContent/css"
<arg value="combined.css" />

The minify task is broken into two parts one is minifyjs which combines and minfies all the JavaScript files in /js folder and the minifycss which combines and minifies all the css files in /css folder.


buyi wen said...

I found a free online service using the YUICompressor to compress the javascript, if someone don't want to code yourself, you can have a try.

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said... is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store