Project

yuicssmin

0.0
No commit activity in last 3 years
No release in over 3 years
The YUICSSMIN gem provides CSS compression using YUI compressor from Yahoo. Unlike other gems it doesn't use the Java applet YUI compressor but instead uses the Javascript port via ExecJS.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.7

Runtime

~> 1.0
>= 0.3.0
>= 1.0.2
 Project Readme

YUICSSMIN Build Status

Ruby wrapper for the Javascript port of YUI's CSS compressor.

The YUICSSMIN gem provides CSS compression using YUI compressor from Yahoo. Unlike other gems it doesn't use the Java applet YUI compressor but instead uses the Javascript port via ExecJS.

Installation

Install YUICSSMIN from RubyGems:

gem install yuicssmin

Or include it in your project's Gemfile:

gem 'yuicssmin'

Usage

require 'yuicssmin'

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

# Alternatively use instance method...

compressor = Yuicssmin.new
compressor.compress(File.read("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):

Yuicssmin.compress(File.read("path/to/styles.css"), 200)

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

Rails asset pipeline

Rails 3.1 integrated Sprockets to provide asset packaging and minimising out of the box. For CSS compression it relies on the yui-compressor gem which requires Java. To use YUICSSMIN instead, edit your config/application.rb file:

config.assets.css_compressor = Yuicssmin.new

Compatibility

Tested with Ruby 1.9.2, 1.9.3, jruby-19mode, rbx-19mode

Changelog

See CHANGES.

Credits

YUICSSMIN gem was inspired by Ville Lautanala's Uglifier gem, released under MIT license.

Copyright

YUICSSMIN gem and documentation

Copyright (c) 2012 Matthias Siegel (matthias.siegel@gmail.com) See LICENSE for details.

YUI compressor

See file.