rev |
line source |
al@18686
|
1 RCSSmin is a CSS minifier written in Python.
|
al@18686
|
2
|
al@18686
|
3 The minifier is based on the semantics of the YUI compressor, which itself is
|
al@18686
|
4 based on the rule list by Isaac Schlueter.
|
al@18686
|
5
|
al@18686
|
6 This module is a re-implementation aiming for speed instead of maximum
|
al@18686
|
7 compression, so it can be used at runtime (rather than during a preprocessing
|
al@18686
|
8 step). RCSSmin does syntactical compression only (removing spaces, comments and
|
al@18686
|
9 possibly semicolons). It does not provide semantic compression (like removing
|
al@18686
|
10 empty blocks, collapsing redundant properties etc). It does, however, support
|
al@18686
|
11 various CSS hacks (by keeping them working as intended).
|
al@18686
|
12
|
al@18686
|
13 Here's a feature list:
|
al@18686
|
14
|
al@18686
|
15 - Strings are kept, except that escaped newlines are stripped
|
al@18686
|
16 - Space/Comments before the very end or before various characters are
|
al@18686
|
17 stripped: ``:{});=>],!`` (The colon (``:``) is a special case, a single
|
al@18686
|
18 space is kept if it's outside a ruleset.)
|
al@18686
|
19 - Space/Comments at the very beginning or after various characters are
|
al@18686
|
20 stripped: ``{}(=:>[,!``
|
al@18686
|
21 - Optional space after unicode escapes is kept, resp. replaced by a simple
|
al@18686
|
22 space
|
al@18686
|
23 - whitespaces inside ``url()`` definitions are stripped
|
al@18686
|
24 - Comments starting with an exclamation mark (``!``) can be kept optionally.
|
al@18686
|
25 - All other comments and/or whitespace characters are replaced by a single
|
al@18686
|
26 space.
|
al@18686
|
27 - Multiple consecutive semicolons are reduced to one
|
al@18686
|
28 - The last semicolon within a ruleset is stripped
|
al@18686
|
29 - CSS Hacks supported:
|
al@18686
|
30
|
al@18686
|
31 - IE7 hack (``>/**/``)
|
al@18686
|
32 - Mac-IE5 hack (``/*\*/.../**/``)
|
al@18686
|
33 - The boxmodelhack is supported naturally because it relies on valid CSS2
|
al@18686
|
34 strings
|
al@18686
|
35 - Between ``:first-line`` and the following comma or curly brace a space is
|
al@18686
|
36 inserted. (apparently it's needed for IE6)
|
al@18686
|
37 - Same for ``:first-letter``
|
al@18686
|
38
|
al@18686
|
39 rcssmin.c is a reimplementation of rcssmin.py in C and improves runtime up to
|
al@18686
|
40 factor 100 or so (depending on the input). docs/BENCHMARKS in the source
|
al@18686
|
41 distribution contains the details.
|
al@18686
|
42
|
al@18686
|
43 The module additionally provides a "streamy" interface:
|
al@18686
|
44
|
al@18686
|
45 $ python -mrcssmin <css >minified
|
al@18686
|
46
|
al@18686
|
47 It takes two options:
|
al@18686
|
48
|
al@18686
|
49 -b Keep bang-comments (Comments starting with an exclamation mark)
|
al@18686
|
50 -p Force using the python implementation (not the C implementation)
|