Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.
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.
It is recommended to install treeshake via pip:
pip install treeshake
To quickly use treeshake, call it via command line:
shake <css dir> <html dir>
python3 -m treeshake <css dir> <html directory>
If you wish to see an interactive prompt, just use shake
or python3 -m treeshake
. The current support is only for a single directory.
To see help, please run: shake -h
.
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')
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.
FAQs
Remove unused css in Python projects with C-powered tree shaking.
We found that treeshake demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.