Minimise your CSS files using by compressing and combining them into one file. Reduce HTTP requests, file size, and save bandwidth.
mini_css compresses using Rainpress,
which is a YUI like CSS compressor built in Ruby, and then merges all the CSS
into one file. You can now compress hundreds of CSS files into one file, with
gem install mini_css
mini_css is simple! You can go about it two ways:
- You can run it from the command line and use it as part of your deployment proceedure.
- You can use it as a class and use the compressed results as necessary.
mini_css from the command line is too simple:
mini_css [-o output_file] file_name[ file_name2 ...]
You can compress one CSS file, or compress more than one, and mash them together as one big compressed file.
You can specify the location and name of the output file; it defaults to mini_cssified.css in the current working directory.
mini_css as a class, simply require the right files and you're away.
require 'rubygems' require 'mini_css' files =  # Fill this aray with file paths. Mini_CSS.compress(files) # mini_css will open them all, compress them, and mash them together
- Parse out @import statements, try to associate them with local files and compress them into the same files too, removing the @import statements as we go.