Ruby port of YUI compressor's CSS engine
Switch branches/tags
Nothing to show
Pull request Compare This branch is 5 commits behind matthiassiegel:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
CHANGES.md
LICENSE.md
README.md

README.md

CSSMIN

Ruby port of YUI compressor's CSS engine.

Based on the original YUI compressor Java code and the Javascript port by Stoyan Stefanov. The Ruby port is complete and passes all test cases that are included in the Java version. However, code and performance improvements are always welcome.

The motivation for this port was to have a native Ruby version without a Java or Javascript dependency.

Usage

require 'path/to/lib/cssmin.rb'

CssCompressor.compress('/* a comment */ .test { display: block; }')
# => minified CSS

CssCompressor.compress(File.read('path/to/styles.css'))
# => minified CSS

CssCompressor.compress(File.open('path/to/styles.css'))
# => minified CSS

Files or strings are acceptable as input.

You can pass in a second argument to control the maximum output line length (default 5000 characters):

CssCompressor.compress(File.read('path/to/styles.css'), 200)

Note: in most cases line length will only be approximated.

Changelog

See CHANGES.

Credits, Copyright and License

See LICENSE for details.