Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect which Bootstrap version is used from JavaScript?

I've been looking at the CSS & JavaScript from Bootstrap 3. Nothing is modularized under a common alias. For the JavaScript, it is injected into jQuery's prototype...

How would it be possible to detect which version of Bootstrap is included in a user's web page from a third party plugin/library point of view with JavaScript?

like image 614
Alerty Avatar asked Jan 26 '14 20:01

Alerty


People also ask

What JavaScript does Bootstrap use?

Bootstrap uses jQuery for JavaScript plugins (like modals, tooltips, etc). However, if you just use the CSS part of Bootstrap, you don't need jQuery.

Is Bootstrap written in JavaScript?

Bootstrap is an HTML, JavaScript framework that you can use as basis for creating web sites or web applications.

Does Bootstrap 5 Use jQuery?

Bootstrap 5 is designed to be used without jQuery, but it's still possible to use our components with jQuery. If Bootstrap detects jQuery in the window object it'll add all of our components in jQuery's plugin system; this means you'll be able to do $('[data-bs-toggle="tooltip"]').


2 Answers

The version of each of Bootstrap's jQuery plugins can be accessed via the VERSION property of the plugin's constructor

$.fn.tooltip.Constructor.VERSION 
like image 167
Kuzenko Lubko Avatar answered Sep 28 '22 03:09

Kuzenko Lubko


As suggested in comments, the only function that seems to be removed in Bootstrap 3 was typehead, even then - there doesn't seem to be a reliable way of detecting which Bootstrap version the site has loaded.

var bsVersion = ( typeof $.fn.typeahead !== 'undefined' ? '2.3.2' : '3.0.0' ); 
like image 36
MackieeE Avatar answered Sep 28 '22 03:09

MackieeE