bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Purge CSS standalone application

Open White-Rabbit-Scientific opened this issue 6 months ago • 2 comments

Prerequisites

Proposal

According to PageSpeed there is significant CSS bloat in my website. This is bad for SEO and also increases download time and computational requirements and memory requirements for my website.

Motivation and context

I ran my homepage through Purify CSS Online. Purify CSS indicated that 84% of the CSS provided by Bootstrap 5.3.6 is unnecessary. Purifying my CSS file would reduce it from 226 kB down to 37 kB.

My suggested resolution is a single executable file that performs the same function as Purify CSS. This could be used as part of the build process for many static site generators such as Zola and Hugo.

White-Rabbit-Scientific avatar Jun 09 '25 04:06 White-Rabbit-Scientific

Personally, I don’t think it's Bootstrap's role to provide and maintain this functionality; tools like PurgeCSS already serve that purpose effectively with a programmatic API, but also a CLI. We recommend using those solutions in our Customize > Optimize > Unused CSS section.

julien-deramond avatar Jun 09 '25 12:06 julien-deramond

Yeah it's also hard to have a singular script that works for every project—there are so many differences between frameworks, languages, platforms, file locations, etc. Perhaps there's more we can front up with a guide or something on getting PurgeCSS setup? We have some of that in our examples—see https://github.com/twbs/examples/tree/main/icons-font.

mdo avatar Jun 09 '25 16:06 mdo

You can use the PurgeCSS CLI to do the same. Its just a one line command.

sreyansjain avatar Jun 29 '25 15:06 sreyansjain