Skip to main content

CSS Minifier

Project description

RCSSmin is a CSS minifier.

The minifier is based on the semantics of the YUI compressor, which itself is based on the rule list by Isaac Schlueter.

This module is a re-implementation aiming for speed instead of maximum compression, so it can be used at runtime (rather than during a preprocessing step). RCSSmin does syntactical compression only (removing spaces, comments and possibly semicolons). It does not provide semantic compression (like removing empty blocks, collapsing redundant properties etc). It does, however, support various CSS hacks (by keeping them working as intended).

Here’s a feature list:

  • Strings are kept, except that escaped newlines are stripped
  • Space/Comments before the very end or before various characters are stripped: :{});=>],! (The colon (:) is a special case, a single space is kept if it’s outside a ruleset.)
  • Space/Comments at the very beginning or after various characters are stripped: {}(=:>[,!
  • Optional space after unicode escapes is kept, resp. replaced by a simple space
  • whitespaces inside url() definitions are stripped, except if it’s a quoted non-base64 data url
  • Comments starting with an exclamation mark (!) can be kept optionally.
  • All other comments and/or whitespace characters are replaced by a single space.
  • Multiple consecutive semicolons are reduced to one
  • The last semicolon within a ruleset is stripped
  • CSS Hacks supported:
    • IE7 hack (>/**/)
    • Mac-IE5 hack (/*\*/.../**/)
    • The boxmodelhack is supported naturally because it relies on valid CSS2 strings
    • Between :first-line and the following comma or curly brace a space is inserted. (apparently it’s needed for IE6)
    • Same for :first-letter

rcssmin.c is a reimplementation of rcssmin.py in C and improves runtime up to factor 100 or so (depending on the input). docs/BENCHMARKS in the source distribution contains the details.

Supported python versions are 2.7 and 3.6+.

Bugs

No bugs, of course. ;-) But if you’ve found one or have an idea how to improve rcssmin, feel free to send a pull request on github or send a mail to <rcssmin-bugs@perlig.de>.

Author Information

André “nd” Malo <nd perlig.de> GPG: 0x029C942244325167

If God intended people to be naked, they would be born that way. – Oscar Wilde

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rcssmin, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size rcssmin-1.1.0.tar.gz (580.8 kB) File type Source Python version None Upload date Hashes View
Filename, size rcssmin-1.1.0-cp310-cp310-manylinux2014_aarch64.whl (43.9 kB) File type Wheel Python version cp310 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp310-cp310-manylinux1_x86_64.whl (43.6 kB) File type Wheel Python version cp310 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp310-cp310-manylinux1_i686.whl (44.0 kB) File type Wheel Python version cp310 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp39-cp39-manylinux2014_aarch64.whl (43.7 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp39-cp39-manylinux1_x86_64.whl (43.4 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp39-cp39-manylinux1_i686.whl (43.9 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp38-cp38-manylinux2014_aarch64.whl (44.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp38-cp38-manylinux1_x86_64.whl (43.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp38-cp38-manylinux1_i686.whl (44.2 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp37-cp37m-manylinux2014_aarch64.whl (44.7 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp37-cp37m-manylinux1_x86_64.whl (44.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp37-cp37m-manylinux1_i686.whl (44.7 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp36-cp36m-manylinux2014_aarch64.whl (43.8 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (43.5 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp36-cp36m-manylinux1_i686.whl (43.8 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp27-cp27mu-manylinux1_x86_64.whl (40.2 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp27-cp27mu-manylinux1_i686.whl (40.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp27-cp27m-manylinux1_x86_64.whl (40.2 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size rcssmin-1.1.0-cp27-cp27m-manylinux1_i686.whl (40.3 kB) File type Wheel Python version cp27 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page