3

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.

3
  • You should download custom bootstrap version where you can select only those library which you need. Plus use javasciprt minifier to remove duplicate or long code. Commented Mar 12, 2017 at 9:53
  • Which minifier would you recommend? Commented Mar 12, 2017 at 10:04
  • Download boostrap SCSS instead and you can comment out particular partial scss files @import _nameOfPartial.scss that you're not needing Commented Mar 15, 2017 at 17:16

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

2 Comments

yea, i have no clue, how to use those node etc stuff. im not gonna lie.
@part you dont need to know how to work with node. you can do: - For css: bootstrap costumizer - For js: uglify To use uglify, you only need to: - install node (latest version, npm is included) - run this on the command line: npm install uglify-js -g - run this on the command line: uglifyjs -c 'dead_code' -- your_file.js
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.