cssmin - YUI CSS Compressor

0.2.0 · maintenance · verified Fri Apr 17

A Python port of the YUI CSS compression algorithm, providing minification for CSS files. The library is currently at version 0.2.0 and has seen minimal updates recently, suggesting a stable but slow release cadence. It aims to replicate the functionality of the original YUI Compressor for CSS.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `cssmin` library and use its `cssmin()` function to minify a string of CSS content. The output will show the minified CSS and its reduced size.

import cssmin

css_content = """
body {
    font-family: Arial, sans-serif;
    color: #333;
}
h1 {
    margin-bottom: 10px;
    /* This is a comment */
    padding: 5px;
}
"""

minified_css = cssmin.cssmin(css_content)

print("Original CSS size:", len(css_content), "bytes")
print("Minified CSS size:", len(minified_css), "bytes")
print("Minified CSS:\n", minified_css)

view raw JSON →