A Maven plugin to compress Javascript files (currently only UglifyJS2 is supported) and aggregate Javascript files. It can also compress CSS files (YUI Compressor).

Based on uglifyjs-maven-plugin (Javascript compression) and yuicompressor-maven-plugin (aggregation, CSS compression).


The plugin can be found in our Maven repository.

To use our repository add the following to your pom.xml:



As this is a typical Maven plugin, simply declare the plugin in the <plugins> section of your pom.xml file:




To compress Javascript and CSS files add the following to the configuration of the plugin:

Parameter Description
directory the path to the base directory of the Javascript/CSS files to compress
excludes a list of all files to exclude (each in a exclude element)
includes a list of all files to include (each in a include element)
copyExcludedFiles flag iff excluded Javascript/CSS files should be copied to the outputDirectory without compression


To aggregate Javascript files, add the following to the configuration:

    <!-- javascript files for all pages -->
Parameter Description
insertNewLine if true a new line is insert between each aggregated Javascript file
includes a list of files to include (each in a include element)
output the path to the aggregated file


Please note: You have to exclude the Javascript/CSS files from the war build:

    <!-- otherwise the Javascript/CSS files compressed by webresource-maven-plugin are overwritten by this plugin -->