part
part

Reputation: 31

How do I remove unused CSS/jQuery?

I'm making a schoolproject, a web page. I got a bootstrap example, which had loads of code in it, but most of it is just random unused css/jQuery. And there is loads of duplicates. It's hard to find anything to be honest.

Is there a way to remove unused css/jQuery from the web page automatically? More interested in jQuery removal.

Upvotes: 3

Views: 2597

Answers (2)

Mohamed Talaat
Mohamed Talaat

Reputation: 196

You can remove your unused css using in a gulp environment using gulp-purgecss.

For more explaination, have a look on this DEMO and read it's docs.

Upvotes: 0

nip
nip

Reputation: 1697

To remove unused css code, you have multiple options:

  1. Use the Bootstrap v3 customizer
  2. Compile the .scss/.less components you need (v4 or v3)
  3. Use uncss (check using uncss with Bootstrap)

To remove unused js code, you also have multiple options:

  1. Google's Closure Compiler (with ADVANCED_OPTIMIZATIONS enabled)
  2. UglifyJS2 (with dead_code option)
  3. Dead Javascript Eliminator

Upvotes: 4

Related Questions