How can I get Bootstrap version via Javascript?

Is there any way to get the Bootstrap version via calling a function? I did some research but couldn’t find any way. The version information is included in the comments at the beginning like this:


But in case the comments are removed how do I get the bootstrap version? Bootstrap plugins have a version defined in them but I’m looking for the general Bootstrap version, not version of a particular plugin.

The version of each of Bootstrap’s jQuery plugins can be accessed via the VERSION property of the plugin’s constructor. For example, for the tooltip plugin:

$.fn.tooltip.Constructor.VERSION // => "3.3.7"

src //

if you mean from the css, then yu ahve to AJAX the file and .match(/v[.\d]+[.\d]/);

You can use this code found here :

  var getBootstrapVersion = function () {
  var deferred = $.Deferred();

  var script = $('script[src*="bootstrap"]');
  if (script.length == 0) {
    return deferred.reject();

  var src = script.attr('src');
  $.get(src).done(function(response) {
    var matches = response.match(/(?!v)([.\d]+[.\d])/);
    if (matches && matches.length > 0) {
      version = matches[0];

  return deferred;

getBootstrapVersion().done(function(version) {
  console.log(version); // '3.3.4'

Checked on the jQuery-less Bootstrap5, to get the version you just neeed

let version = bootstrap.Tooltip.VERSION

This spinoff of the Constructor method adds a fallback plugin and returns an array:

var version = ($().modal||$().tab).Constructor.VERSION.split('.');

You can access the major revision with version[0], of course.

you can find bootstrap version here:

$.fn.tooltip.Constructor.VERSION // => "4.3.1"

If you want a solution that works for all the currently supported versions of Bootstrap (3.x, 4.x, 5.x), this should work:

var version = typeof bootstrap === 'undefined' ?
   $().tooltip.Constructor.VERSION : bootstrap.Tooltip.VERSION;

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   How to detect Click + [Shift, Ctrl, Alt] in reactjs click event?

Similar Posts