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

  • 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 50 or so (depending on the input).

Both python 2 (>= 2.4) and python 3 are supported.

Bugs

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

Author Information

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

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

Project details


Download files

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

Source Distribution

rcssmin-1.0.2.tar.gz (65.4 kB view details)

Uploaded Source

File details

Details for the file rcssmin-1.0.2.tar.gz.

File metadata

  • Download URL: rcssmin-1.0.2.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rcssmin-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b6312d0ada6e2ca190b03cae3a28bbe95ef7652cf66a7a9cff62df261517205f
MD5 7c399d499fceb8fa7bf1de744df72755
BLAKE2b-256 ec1a3fe2c110a8e6a04a450bdc5ff2e5a6da77f3222fb57bb705020553976b33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page