What's new? | Help | Directory | Sign in
Google
jsmin-ant-task
A custom task for Apache Ant which acts as an interface to the JSMin program.
  
  
  
  
    
Show all Featured Downloads:
jsmin.0.2.2.jar

JSMin Ant Task

A custom task for Apache Ant which acts as an interface to the JSMin program.

About JSMin

"JSMin is a filter which removes comments and unnecessary whitespace from javascript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation."

Excerpt from Douglas Crockford's JSMin page

Description

The JSMin Ant task acts as an interface to the JSMin Java class. The task can be used for the automated minification of javascript files in your build and deploy processes.

Parameters

Attribute Description Required
srcfile Specify a javascript source file to be minified. Yes, unless a nested fileset has been specified.
suffix If true suffix minified files with .min. IE: file.js becomes file.min.js. Default is false. No
destdir The destination directory for minified files to be outputted to. Task defaults to the files source directory if ommitted. No
force Overwrite a destination file if it already exists. Default is false No

Examples

Define the task in your build file:

<taskdef name="jsmin"
        classname="net.matthaynes.jsmin.JSMin_Task"
        classpath="/path/to/jsmin.jar"/>

Using the task on a single file, with the .min suffix added to the file extension:

<jsmin srcfile="file.js" suffix="true" />

Using the task with a fileset, and an output directory specified:

<jsmin destdir="./outputdirectory">
       <fileset dir="./somejsdirectory/" includes="**/*.js"/>
</jsmin>

Support

If you have any issues then please let us know, I will see what I can do. I would also be very interested to hear what platforms and Ant versions people are using as I have not had time to extensivley test this task.