Benedikt Meurer JavaScript Engine Hacker and Programming Language Enthusiast.

WebsiteCompressor

WebsiteCompressor is a small, fast and very easy to use Java utility that minifies a whole website, with all CSS, HTML, JavaScript and XML files by removing extra whitespaces, comments and other unneeded characters without breaking the content structure. As a result the pages become smaller in size and load faster.

Under the hood it utilizes the famous HtmlCompressor to minify HTML and XML files and Yahoo!'s YUI Compressor to minify CSS and JavaScript files (and optionally also minify inline CSS and JavaScript in HTML files).

Download #

Note that you need to have Java SE 1.5 or better (Java SE 1.6 recommended) installed in order to use the WebsiteCompressor.

Usage #

Download the latest release, extract the archive, and copy all JAR files from the archive to your website project.

Usage: java -jar websitecompressor-0.4.jar [options] [files]

<files or folders>          The files are compressed in-place

Global Options:
 --charset <charset>        Read the input files using <charset>
 -h, --help                 Print this screen

CSS Compression Options:
 --line-break <column>      Insert a line break after the specified column number

HTML Compression Options:
 --compress-css             Enable inline CSS compression
 --compress-js              Enable inline JavaScript compression
 --preserve-comments        Preserve comments
 --preserve-intertag-spaces Preserve intertag spaces
 --preserve-line-breaks     Preserve line breaks
 --preserve-multi-spaces    Preserve multiple spaces
 --preserve-quotes          Preserve unneeded quotes

JavaScript Compression Options:
 --disable-optimizations    Disable all micro optimizations
 --line-break <column>      Insert a line break after the specified column number
 --nomunge                  Minify only, do not obfuscate
 --preserve-semi            Preserve all semicolons

XML Compression Options:
 --preserve-comments        Preserve comments
 --preserve-intertag-spaces Preserve intertag spaces

Please note that additional HTML Compressor and YUI Compressor jar
files must be present in the same directory as this jar file.

Example #

For example, use the following commands to minify a website generated by Jekyll using the WebsiteCompressor (assuming that you placed the JAR files in a subdirectory named _lib, which is then ignored by Jekyll):

cd /path/to/website
jekyll --no-server
java -jar _lib/websitecompressor-0.4.jar --compress-css --compress-js _site

Afterwards upload the contents of the _site folder to your webserver as usual.

Warning #

WebsiteCompressor performs all compression in-place, so do not run WebsiteCompressor on your original source files! Create a copy of your website files first, run WebsiteCompressor on the copy and upload it to your webserver afterwards.

License #

WebsiteCompressor is licensed under the Apache License 2.0. See the LICENSE file for details.

Source code

Available on GitHub: https://github.com/bmeurer/websitecompressor

Download it in either zip or tar formats.

Clone the project with Git by running:

git clone git://github.com/bmeurer/websitecompressor.git

Bug Reports

If you come across any problems, please create a ticket and we will try to get it fixed as soon as possible.

Report a Bug

Contributing

Once you have made your commits:

  1. Fork websitecompressor.
  2. Create a topic branch - git checkout -b my_branch
  3. Push to your topic branch - git push origin my_branch
  4. Create a Pull Request from your topic branch.
  5. That's it!

Fork websitecompressor

Copyright © 2010-2011 Benedikt Meurer. See the LICENSE file for details.