• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1==============
2 CSS Minifier
3==============
4
5RCSSmin is a CSS minifier.
6
7The minifier is based on the semantics of the `YUI compressor`_\, which itself
8is based on `the rule list by Isaac Schlueter`_\.
9
10This module is a re-implementation aiming for speed instead of maximum
11compression, so it can be used at runtime (rather than during a preprocessing
12step). RCSSmin does syntactical compression only (removing spaces, comments
13and possibly semicolons). It does not provide semantic compression (like
14removing empty blocks, collapsing redundant properties etc). It does, however,
15support various CSS hacks (by keeping them working as intended).
16
17Here's a feature list:
18
19- Strings are kept, except that escaped newlines are stripped
20- Space/Comments before the very end or before various characters are
21  stripped: ``:{});=>+],!`` (The colon (``:``) is a special case, a single
22  space is kept if it's outside a ruleset.)
23- Space/Comments at the very beginning or after various characters are
24  stripped: ``{}(=:>+[,!``
25- Optional space after unicode escapes is kept, resp. replaced by a simple
26  space
27- whitespaces inside ``url()`` definitions are stripped
28- Comments starting with an exclamation mark (``!``) can be kept optionally.
29- All other comments and/or whitespace characters are replaced by a single
30  space.
31- Multiple consecutive semicolons are reduced to one
32- The last semicolon within a ruleset is stripped
33- CSS Hacks supported:
34
35  - IE7 hack (``>/**/``)
36  - Mac-IE5 hack (``/*\*/.../**/``)
37  - The boxmodelhack is supported naturally because it relies on valid CSS2
38    strings
39  - Between ``:first-line`` and the following comma or curly brace a space is
40    inserted. (apparently it's needed for IE6)
41  - Same for ``:first-letter``
42
43rcssmin.c is a reimplementation of rcssmin.py in C and improves runtime up to
44factor 100 or so (depending on the input). docs/BENCHMARKS in the source
45distribution contains the details.
46
47Both python 2 (>= 2.4) and python 3 are supported.
48
49.. _YUI compressor: https://github.com/yui/yuicompressor/
50
51.. _the rule list by Isaac Schlueter: https://github.com/isaacs/cssmin/
52
53
54Copyright and License
55~~~~~~~~~~~~~~~~~~~~~
56
57Copyright 2011 - 2014
58André Malo or his licensors, as applicable.
59
60The whole package (except for the files in the bench/ directory) is
61distributed under the Apache License Version 2.0. You'll find a copy in the
62root directory of the distribution or online at:
63<http://www.apache.org/licenses/LICENSE-2.0>.
64
65
66Bugs
67~~~~
68
69No bugs, of course. ;-)
70But if you've found one or have an idea how to improve rcssmin, feel free
71to send a pull request on `github <https://github.com/ndparker/rcssmin>`_
72or send a mail to <rcssmin-bugs@perlig.de>.
73
74
75Author Information
76~~~~~~~~~~~~~~~~~~
77
78André "nd" Malo <nd perlig.de>
79GPG: 0x8103A37E
80
81
82    If God intended people to be naked, they would be born that way.
83    -- Oscar Wilde
84
85.. vim:tw=72 syntax=rest
86