Package tdi :: Package tools :: Module rcssmin
[frames] | no frames]

Module rcssmin

source code

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:

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.

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


Copyright: Copyright 2011 - 2015 André Malo or his licensors, as applicable

License:

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Version: 1.0.6

Author: André Malo

Functions
str
cssmin(style, keep_bang_comments=False)
Minify CSS.
source code
Function Details

cssmin(style, keep_bang_comments=False)

source code 
Minify CSS.
Parameters:
  • style (str) - CSS to minify
  • keep_bang_comments (bool) - Keep comments starting with an exclamation mark? (/*!...*/)
Returns: str
Minified style