How to remove the excess CSS from bootstrap.min.css

Try https://purgecss.com/

Very easy to use, as long as you have node.js installed

In command line, install with:

npm i -g purgecss

then navigate to your export directory. Create a new folder called ‘purged’ (or anything you like)

then run the command below:

purgecss --css *.css **/*.css --content *.html *.js --output purged

The rewritten css files will then be stored in the ‘purged’ folder make sure you have the folder name after output

The *.js is to check to see if you have any styles dynamically generated in javascript so you could leave that out.

It should take bootstrap.min.css down to average 20kb, down from 159kb, depending on how much bootstrap you actually use.

1 Like