Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Css Purger Laravel Package

jbsnewmedia/css-purger

A Laravel package for purging unused CSS. It scans your templates and views to find which selectors are actually used, then removes the rest to shrink stylesheets and speed up page loads. Configurable paths make it easy to fit into existing projects.

Deep Wiki
Context7

jbsnewmedia/css-purger is a Laravel package that strips unused CSS rules from your stylesheets so you can ship leaner, faster front ends. It scans your rendered pages for the selectors actually in use, then purges the rest—ideal for trimming framework bloat before production.

  • Blade-aware scanning of rendered HTML to detect live selectors
  • Safe purging with a configurable safelist for dynamic or JS-added classes
  • Artisan commands for one-off purges or build pipelines
  • Flexible output to overwrite originals or emit separate purged copies
Frequently asked questions about Css Purger
What does jbsnewmedia/css-purger do in a Laravel app?
CssPurger removes unused CSS rules from stylesheets used by your Laravel application. It works by scanning Blade views and rendered HTML to find which classes are actually used, then strips rules that do not match. This is especially useful for trimming large CSS frameworks like Bootstrap.
How do I install jbsnewmedia/css-purger with Composer?
Install the package with Composer using the name jbsnewmedia/css-purger. After installation, follow the package's Laravel setup instructions for any required configuration or registration. Run your first purge in a staging environment before applying it to production stylesheets.
How does CssPurger decide which CSS rules are unused?
It scans the HTML and Blade templates you point it at and collects the CSS class names that appear in the markup. Any CSS rule whose selectors do not match those detected classes is treated as unused and removed. Whitelisting lets you protect classes that are added dynamically and would otherwise be missed.
Can CssPurger scan both Blade views and rendered HTML?
Yes, the package is described as scanning Blade views and rendered HTML for class usage. Scanning rendered HTML helps catch classes that appear after Laravel renders a view, while Blade scanning covers template source. Use both approaches where possible to reduce false positives.
How do I whitelist dynamic classes that JavaScript adds at runtime?
CssPurger provides whitelisting so classes that do not appear in scanned Blade or HTML output are not purged. Add the class names used by your JavaScript components, toggles, modals, and third-party widgets to the whitelist. Review the whitelist after adding new frontend behavior, and test interactions in staging.
Does CssPurger work with Bootstrap and other CSS frameworks?
Yes, the package is intended for optimizing large stylesheets such as Bootstrap based on actual usage in your project. Frameworks often include many rules your app never uses, so purging can shrink the final CSS. Test every major component and state, because framework classes can be applied conditionally.
Is it safe to purge CSS in a production Laravel application?
Purging can be safe if you test thoroughly, keep backups of the original CSS, and whitelist dynamic classes. Because CssPurger removes rules based on detected usage, missing classes from JavaScript or user-generated content can cause visual regressions. Start in staging, compare key pages, and only then deploy the purged stylesheet.
How do I configure CssPurger for my Laravel project?
Configuration focuses on which templates or HTML sources to scan and which class names to whitelist. Check the package documentation for the exact configuration file and option names for your version. Begin with a conservative whitelist and a staging purge so you can review the diff before production.
Which Laravel versions are supported by CssPurger?
The provided package context does not list supported Laravel versions. Check the package's composer.json and README for version constraints before installing it in your application. If your Laravel release is not confirmed, test the package in a separate branch or staging environment first.
Can I use CssPurger outside Laravel or with plain PHP?
The package overview calls CssPurger a lightweight PHP library, while the package blurb presents it as a Laravel package. It may be usable in plain PHP if the core library is exposed, but confirm that in the documentation. For Laravel projects, use the documented Laravel integration to scan Blade views and rendered HTML.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console