Skip to content

CSS minifier written in Java which uses YUI CSS Compressor

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE.yuicompressor
Notifications You must be signed in to change notification settings

corgrath/osbcp-css-squasher

Repository files navigation

OSBCP CSS Squasher

OSBCP CSS Squasher is simply a clever CSS squasher tool, written in Java, that converts CSS like this:

a {
	width: 100px;
	color: red;
}

b {
	width: 100px;
	color: red;
}

c {
	color red;
}

d, e {
	margin: 10px;
}

e, d {
	padding: 10px;
}

To this:

a, b {
	width: 100px;
}

a, b, c {
	color: red;
}

d, e {
	margin: 10px;
	padding: 10px;
}

By merging, squashing and refactoring your CSS code and then it uses the YUI Compressor to turn it into this:

a,b{width:100px}a,b,c{color:red}d,e{margin:10px;padding:10px}

Try it yourself

Click here for an online demo tool.

Read the blog entry

Introducing OSBCP CSS Squasher - YUI CSS Compressor gone clever?

Download

Download the latest version here:

https://github.com/corgrath/osbcp-css-squasher/downloads/

Dependencies:

How to use it as a stand alone application

Usage:

java -jar osbcp-css-squasher-x.y.z.jar [input file]

Requires the following libraries in the same folder for Squasher 1.1:

  • yuicompressor-2.4.7.jar
  • osbcp-css-parser-1.5.jar
  • commons-io-2.1.jar

Other wise you you need to type

How to use it in a Java project

package com.osbcp.csssdfasher;

import java.util.List;

import org.apache.commons.io.IOUtils;

import com.osbcp.cssparser.Rule;
import com.osbcp.csssquasher.ResultObject;
import com.osbcp.csssquasher.Squasher;

public class TestApp {

	public static void main(final String[] args) throws Exception {

		String contents = IOUtils.toString(Squasher.class.getResourceAsStream("stylesheet.css"));

		// Squash!
		ResultObject results = Squasher.squash(contents);

		// Get the original CSS
		String originalCSS = results.getOriginalCSS();

		// Get the refactored CSS
		String refactoredCSS = results.getRefactoredCSS();

		// Get the compressed CSS
		String comrpressedCSS = results.getCompressedCSS();

		// Get all the CSS rules
		List<Rule> rules = results.getRules();

		// Get the log
		String log = results.getLog();

	}

}

Please view the JavaDoc for additional information.

JavaDoc

http://dl.dropbox.com/u/8183146/persistent/projects/java_osbcp_css_squasher/javadoc/index.html

Comparison numbers

Here are some fancy numbers compared to just using the YUI Compressor.

Fancy numbers

Please report bugs

Please report any bugs by creating a new issue.

Changes

v1.1 2012-04-28

  • Added manifest file.

v1.0 2012-02-02 Christoffer Pettersson

  • Initial release

License

OSBCP CSS Squasher Copyright 2012 Christoffer Pettersson, christoffer[at]christoffer.me.

Licensed under the Apache License, Version 2.0

About

CSS minifier written in Java which uses YUI CSS Compressor

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE.yuicompressor

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages