MiniWeb is a full-website minifier that compresses integrated HTML, CSS, and JavaScript while preserving full functionality. It removes HTML classes that aren't referenced by the CSS and optimally shortens the remaining class names based on their frequency. MiniWeb handles HTML minification itself, while relying on YUI Compressor for CSS and JS minification. It is designed to be used both from the command-line and as a Java library.
From the command-line:
- Make sure you have a recent version of Java.
- Download the latest release.
- Run
java -jar MiniWeb.jar [... html files ...].
As a library:
- Download the latest release.
- Add
import miniweb.MiniWebto your source code. - Call the relevant
MiniWeb.minify(...)method.
-
MiniWeb has several command-line options. Run
java -jar MiniWeb.jar --helpto get an overview. -
If you need to exclude specific class names from deletion or munging, add a file called
miniweb.propertiesin a directory that contains one of your HTML files, and give it the following text:removeUnusedClasses = [true or false] dontRemove = [a space-separated list of class names] mungeClassNames = [true or false] dontMunge = [a space-separated list of class names]For example, the following prevents the class names
selectedandtestfrom being shortened and preventstestfrom being removed:removeUnusedClasses = true dontRemove = test mungeClassNames = true dontMunge = test selected
- Bug reports and pull requests are welcome!
- By submitting a pull request, you assert that you own the rights to any code you contribute and grant me an irrevocable right to publish this code under the current license of this project.
MiniWeb is © 2016-2017 Sander Verdonschot and is released under the Apache License, Version 2.0.
MiniWeb includes distributable versions of the following libraries and their dependencies:
- YUI Compressor, released under the BSD license with parts under the Mozilla Public License (MPL).
- JSoup, released under the MIT license.
- jStyleParser, released under the GNU Lesser General Public License (LGPL), version 3.
- JCommander, released under the Apache License, Version 2.0.