Skip to main content

Remove unused css in Python projects with C-powered tree shaking.

Project description

Treeshake

Ever used a CSS framework and cried about all the overhead it caused? Ever wrote so much CSS that you were no longer aware what parts of it were actually used? Fear no more. Just use treeshake before deployment and all of your troubles will melt away.

Dead code elimination

Tree shaking is a concept mostly used in ECMAScript languages like Dart, JavaScript and Typescript that helps to eliminate unused code. Optimizing your code in a single bundle.

This project aims to bring the power of tree shaking for css to your Python projects. This small library is written in Cython and allows you to get the best performance out of your (potentially) bloated web applications.

Quick example

The following piece of codes recursively adds all css files from /styles/ and all html files from /html and compares the contents. Where possible, it will eliminate styling.

The new file is written to the /out/ output directory.

from treeshake import Shaker

treeshaker = Shaker()
treeshaker.discover_add_stylesheets('./styles/', True)
treeshaker.discover_add_html('./html/', True)
treeshaker.optimize('./out')

Command line support

In the near future, we aim to provide a simple cli command to quickly start tree shaking directories. This feature is currently planned and expected to arrive in v0.2.0.

Contributing

Any contribution to this project is very welcome. Please open an issue when you are dealing with a problem or want to discuss a feature. All contributions are handled by pull requests.

Please refer to CONTRIBUTING.md for more information.

Project details


Download files

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

Source Distribution

treeshake-0.1.5.tar.gz (92.0 kB view details)

Uploaded Source

Built Distribution

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

treeshake-0.1.5-cp39-cp39-macosx_11_0_x86_64.whl (103.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

File details

Details for the file treeshake-0.1.5.tar.gz.

File metadata

  • Download URL: treeshake-0.1.5.tar.gz
  • Upload date:
  • Size: 92.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for treeshake-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bf7e0f9c7542f5b05ba7959cd5227879eace6f2acc10136f7f1e3f8dd607e8ba
MD5 777cf8438e9801858bb82bbe15d5810f
BLAKE2b-256 fee72a085685099e601710ca8910377d7882c4232f0aade844bc0e0c81b836bb

See more details on using hashes here.

File details

Details for the file treeshake-0.1.5-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: treeshake-0.1.5-cp39-cp39-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 103.7 kB
  • Tags: CPython 3.9, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for treeshake-0.1.5-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f7ebeedb623468138117d9f8ffc0d1342a2386ced825e8c2552e9d1afd2e2ee3
MD5 fcb06cce50bd945780b2f12de8dceb79
BLAKE2b-256 573f814bfa149f0b90a61da00c2c7ddd1277f686977e6c2bdf4d50534cbf7922

See more details on using hashes here.

Supported by

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