Why Does Bootstrap Require jQuery?

11,673

Solution 1

In hindsight it's easy to judge (as you are doing rather shortsightedly), but back in 2011 jQuery was not considered bloated or outdated and was the main proven library that offered easy DOM access. So in that context it made perfect sense to use jQuery.

In fact, 6 years later there may still not be another library with the same robustness and feature set of jQuery.

Solution 2

Jquery is a popular frame work and lots of developers have experience writing in it, making their documentation easier to digest. It's also very good at dealing with a lot of the cross browser quirks that javascript presents.

If you really don't want to use Jquery, there is bootstrap native: http://thednp.github.io/bootstrap.native/

Share:
11,673
Rabadash8820
Author by

Rabadash8820

The first thing I learned to program was my TI-84 calculator. Now I can program other things.

Updated on July 03, 2022

Comments

  • Rabadash8820
    Rabadash8820 almost 2 years

    I have googled this question numerous times and never found a satisfactory answer. Most answers seem only to say that "yes, Bootstrap plugins do require jQuery" or "yes, you can use BS without jQuery if you don't use the plugins". Bootstrap's reliance on jQuery (as described in their quick start) strikes me as a poor design decision, for at least the following reasons:

    1. jQuery is quite a large and bloated framework, and now any site using BS plugins will have to download it. Granted, BS users can use the slim/minified builds (unless they want to use jQuery AJAX), but even those add not-insignificant load time for a library that may not be used by anything but Bootstrap.
    2. jQuery in general seems to be falling out of favor lately, as frameworks like Angular and React grow more popular (see StackOverflow trends). I know old != bad, and jQuery is still almost ubiquitous on the web, but why did the BS developers choose to rely on an over-decade-old framework?
    3. Simply requiring jQuery to be <script>ed in before BS does not allow for very clear dependency resolution with modern bundlers like Webpack and SystemJS. Again, why didn't they use some kind of module-based dependency?
    4. But most importantly, in my opinion: why did the BS developers choose to rely on a JS framework at all?? In this wonderful age of standards-compliant browsers, most of jQuery's features can now be accomplished with vanilla HTML/CSS/JS. We all know that when creating a software package/library of any kind, we should try to remove additional dependencies whenever feasible, because users want that package and not a bunch of other additional fluff.

    So is there some reason, then, that the BS devs chose to rely on jQuery, in spite of all of the above? I probably could've just asked the BS devs directly with an Issue on their GitHub page, but I hoped that an SO question would be more accessible to future googlers with these questions.

    Update Jan 2019: According to the Bootstrap docs, v5 is dropping the jQuery dependency, so hopefully that will arrive soon.

    Update May 2021: Bootstrap v5 is out! As promised, this version has dropped jQuery, as described in the release blog post.