Registry / devops / rcssmin

rcssmin

JSON →
library1.2.2pypypi✓ verified 25d ago

RCSSmin is a CSS minifier written in Python, based on the semantics of the YUI compressor. It prioritizes speed over maximum compression, performing syntactical compression only by removing spaces, comments, and semicolons, while supporting various CSS hacks. It includes a C re-implementation (`rcssmin.c`) that significantly improves runtime performance. The current version is 1.2.2.

pip install rcssmin
INSTALL
IMPORT
SIG · RCSSMIN
R
rcssmin
devopspythonv1.2.2
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cssmin
from rcssmin import cssmin
The primary function for minifying CSS.

This example demonstrates basic CSS minification and how to optionally preserve 'bang comments' (comments starting with `!`).

import rcssmin css_input = """\ /* This is a comment */ body { color: #fff; /* inline comment */ font-size: 16px; /*! Important comment */ } .container { margin: 0 auto; } """ # Basic minification minified_css = rcssmin.cssmin(css_input) print(f"Basic Minified:\n{minified_css}") # Expected: body{color:#fff;font-size:16px}.container{margin:0 auto} # Keep 'bang comments' (comments starting with !) minified_with_bang = rcssmin.cssmin(css_input, keep_bang_comments=True) print(f"\nMinified with Bang Comments:\n{minified_with_bang}") # Expected: body{color:#fff;font-size:16px/*! Important comment */}.container{margin:0 auto}
rcssmin --version
Debug
Known issues
gotchaInstalling `rcssmin` on Windows (and some other platforms) might require a C compiler (e.g., Visual C++ Build Tools) to build its faster C extension (`rcssmin.c`). Without a compiler, the installation might fall back to the slower pure Python implementation, or fail entirely if not properly handled by `pip`.
fix
Ensure a C compiler is available on the system, or manually force the pure Python installation if performance is not critical (e.g., `pip install --no-binary :all: rcssmin`).
affects: All versions with C extension (since 1.0.0).
gotcha`rcssmin` performs only *syntactical* CSS compression (e.g., stripping spaces, comments, semicolons). It does not perform *semantic* compression, such as removing empty CSS blocks, collapsing redundant properties, or short-handing properties. Users expecting deeper optimization should consider other tools or combine `rcssmin` with a semantic optimizer.
fix
Understand `rcssmin`'s scope; for semantic optimization, integrate other tools into your build pipeline.
affects: All versions
gotchaBy default, `rcssmin.cssmin` removes all comments. To preserve 'bang comments' (comments starting with an exclamation mark, e.g., `/*! License */`), you must explicitly set the `keep_bang_comments=True` parameter.
fix
Pass `keep_bang_comments=True` to the `cssmin` function to retain desired comments.
affects: All versions
gotchaWhile older versions of `rcssmin` and its documentation might mention Python 2.7 support, the library is primarily developed and tested for Python 3.6+. Recent distribution packages have also dropped Python 2 support. For reliable and performant operation, use Python 3.6 or newer.
fix
Ensure your project uses Python 3.6 or a later version for compatibility and optimal performance.
affects: < 1.0.6 (Python 2.7, 3.6+); >= 1.0.6 (Python 3.6+ recommended)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rcssmin'
The rcssmin package is not installed in the current Python environment.
fix
pip install rcssmin
TypeError: argument of type 'int' is not iterable
The rcssmin.cssmin() function expects a string containing CSS code as input, but received an incompatible type.
fix
Ensure the input to rcssmin.cssmin() is a string, for example: rcssmin.cssmin('body { color: red; }')
AttributeError: module 'rcssmin' has no attribute 'minify_css'
The user attempted to call a non-existent method; the correct function for minifying CSS is cssmin.
fix
Use rcssmin.cssmin() instead of rcssmin.minify_css().
Upgrade
Version history
1.2.2latest on PyPI · released Oct 12, 2025
Audit
Dependencies
pythonrequiredRuntime dependency for the Python implementation.
setuptoolsrequiredCommon build-time dependency for Python packages, especially those with C extensions.
C compileroptionalRequired for compiling the faster C extension (rcssmin.c) during installation. If unavailable, the slower Python implementation is used.
Agent activity
14 hits · last 30 days
node
10
Resources
rcssmin — pip install rcssmin · libregistry