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
Bootstrap Introduction
Bootstrap Get Started
Bootstrap Setup and Installation
Migrating from Bootstrap 4 to Bootstrap 5
Bootstrap Cheat Sheet
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What is Bootstrap?
What are the advantages of Bootstrap?
Who developed Bootstrap and when?
How do you add Bootstrap to a web page?
What is the difference between bootstrap.bundle.js and bootstrap.js?
Is jQuery required for Bootstrap 5?
What are the main differences between Bootstrap 4 and Bootstrap 5?