Simple HTTP service with an embeded yuicompressor engine

Download .zip Download .tar.gz View on GitHub


A pure java HTTP service with an embedded yuicompressor engine

Build Status

Powered by jetty, ehcache and yui-compressor and inspired on fotonaut's yuicompressor-server


  • git
  • jdk 1.7
  • mvn 3


Clone the project and install it!

$ git clone https://github.com/kpacha/yuicompressor-server.git
$ cd yuicompressor-server
$ mvn install

And, after testing the code, the yuicompressor-server-0.2.2-SNAPSHOT.jar should be on your local maven repo

Run with maven

If the first test is hard, people usually quit the test... So check this out! Just type one more maven command and done!

$ mvn clean compile exec:java

Your service should be waiting for you at port 8080. Nice, uh?

Build and Run the fat-jar

So, let's build it for real, deploy it to an actual server and run it!

$ mvn clean compile assembly:single
# ...and you are ready for deploy the fat-jar!

# ... your deployment process here ...

# start the yuicompressor service
$ java -jar target/yuicompressor-server-0.2.2-SNAPSHOT-jar-with-dependencies.jar [-p <PORT>] [-c] [-m <MAX_INPUT_SIZE>]

Note the optional arguments!

-c         enable cache
-p <arg>   port (default 8080)
-m <arg>   max input size (default 1024000 bytes)

And you already have a yuicompressor-server running!


Just send your javascript and css files as a post request to your service. The server checks the integrity of the request using the Content-MD5 header, so you need to add this header with the MD5 of the file sent.

Simple demo with curl:

$ curl -H "Content-MD5: acf0ae0101e6762933ee7036297851fd" --data-urlencode "type=css" --data-urlencode "files=main.css" --data-urlencode "input=a {}       c{ color=red;      }" http://localhost:8080/
# or
$ curl -H "Content-MD5: " --data-urlencode "type=js" --data-urlencode "files=main.js" --data-urlencode "input@main.js" http://localhost:8080/


Supose you have several hosts where you have to compress your javascript and css files. Why would you spend so much time doing the same operation again and again? And are your files different from one host to another or are they almost the same? How often do you deploy? Just take the DRY pattern to the next abstraction level and delegate that process to a dedicated service!

Bitdeli Badge