How can you reduce the size of the Bootstrap CSS and JS?

  • Sass: import only the components you need, instead of the full bootstrap.scss file. See Bootstrap Customization.
  • JavaScript: with a bundler, import only the plugins you use: import { Modal } from 'bootstrap';
  • Use the utility API of Sass to remove the utilities you do not use.
  • Serve the files with gzip or brotli and a long cache time (a CDN does it).
  • A tool that removes the unused CSS (like PurgeCSS) can also help, but test it well.

Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.