Python modules you should know: cssmin

April 29, 2012 at 02:10 PM | categories: Python, PyMYSK, Howto | View Comments

Next in our series of Python modules you should know is cssmin. Minification has recently gained prominence in the web 2.0 world due to the need to optimize web application performance.

The cssmin package is used to minify css files.

Home page


cssmin is a Python port of the YUI CSS Compressor. It is used to minify css files, which helps improve web application performance by reducing page load times.


pip install cssmin


The package provides a command line interface as well as Python functions.

Python function

import cssmin
minified = cssmin.cssmin(open('style.css').read())
print minified


cssmin --wrap 1000 < style.css > style.min.css

Thats it, nice and sweet.

blog comments powered by Disqus