Skip to main content

csscompress

A fast and safe CSS minifier for Python — the community-maintained fork of csscompressor (itself a Python port of YUI Compressor's CSS minifier).

What's fixed vs upstream

Upstream csscompressor is dormant (last release 0.9.5, November 2017). csscompress continues it with:

  • Data-URI whitespace fix: url("data:...") values containing SVG or MathML were minified aggressively (remove_ws=True), destroying the whitespace that SVG/MathML data URIs need to render. csscompress preserves whitespace inside url(...) patterns, so data:image/svg+xml,... CSS works after minification.
  • Proper __version__ attribute (upstream shipped a stale one).

Usage

from csscompress import compress

minified = compress("body { color: #ff0000; /* comment */ }")

There is also a CLI:

$ python -m csscompress input.css > output.min.css

API

  • compress(css: str) -> str — minify a CSS stylesheet.
  • compress_partitioned(css: str) -> list[str] — minify and return each top-level rule separately.

License

BSD (revised) — see LICENSE. The original project is a Python port of the YUI Compressor CSS minifier:

  • Portions Copyright (c) 2013 Sprymix Inc.
  • Author of the Python port: Yury Selivanov
  • Original authors: Julien Lecomte, Isaac Schlueter, Stoyan Stefanov, and contributors; Portions Copyright (c) 2011-2013 Yahoo! Inc.

Download files

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

Source Distribution

csscompress-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csscompress-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file csscompress-0.1.0.tar.gz.

File metadata

  • Download URL: csscompress-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for csscompress-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e87e0d26bd904b8c544d1ca3327a9fa99ae61ce72d04153e0e7fe9fe1179cca
MD5 9a05d4cc6501ee5ec77e7a530477d77b
BLAKE2b-256 8d31eb99ae11fec861cc99bbaaacde146c3cc88db963d7f29f6ea0f493caee16

See more details on using hashes here.

Provenance

The following attestation bundles were made for csscompress-0.1.0.tar.gz:

Publisher: release.yml on QQSHI13/csscompress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file csscompress-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: csscompress-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for csscompress-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8977d6fac07954778d6ffaa83ee23edd66391dcd61f01d97448e708b863a2be7
MD5 322ae25e8147a5db0a474965f27a2595
BLAKE2b-256 b54a3a50aa62cffdcc7c90a36e3eb1095b462966de85a0d43108cdeae2075350

See more details on using hashes here.

Provenance

The following attestation bundles were made for csscompress-0.1.0-py3-none-any.whl:

Publisher: release.yml on QQSHI13/csscompress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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