dotnet/AspNetCore.Docs · error · Error

Bootstrap's JavaScript requires jQuery version 1.9.1 or high

Error message

Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4

What it means

Immediately after the jQuery-present check, Bootstrap 3.3.7 parses $.fn.jquery and asserts the version is >= 1.9.1 and < 4. Bootstrap 3 was written against jQuery 1.9–2.x/3.x APIs; jQuery 1.8 lacks APIs it needs and jQuery 4 removed others. Out-of-range versions throw on load.

Source

Thrown at aspnetcore/mvc/controllers/testing/samples/3.x/TestingControllersSample/src/TestingControllersSample/wwwroot/js/bootstrap.js:15

/*!
 * Bootstrap v3.3.7 (http://getbootstrap.com)
 * Copyright 2011-2016 Twitter, Inc.
 * Licensed under the MIT license
 */

if (typeof jQuery === 'undefined') {
    throw new Error('Bootstrap\'s JavaScript requires jQuery')
  }
  
  +function ($) {
    'use strict';
    var version = $.fn.jquery.split(' ')[0].split('.')
    if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) {
      throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4')
    }
  }(jQuery);
  
  /* ========================================================================
   * Bootstrap: transition.js v3.3.7
   * http://getbootstrap.com/javascript/#transitions
   * ========================================================================
   * Copyright 2011-2016 Twitter, Inc.
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * ======================================================================== */
  
  
  +function ($) {
    'use strict';
  
    // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
    // ============================================================
  

View on GitHub (pinned to c67a80103a)

Solutions

  1. Use a jQuery version in the supported range (1.9.1 up to and including 3.x).
  2. If you must use jQuery 4, upgrade Bootstrap to v5+ which supports it.
  3. Pin the jQuery version explicitly in your bundle/CDN rather than @latest.

Example fix

// before
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
<script src="bootstrap.js"></script> <!-- throws -->
// after
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="bootstrap.js"></script>
Defensive patterns

Strategy: validation

Validate before calling

// Verify jQuery version range before assuming Bootstrap 3 will load.
function jqueryVersionOk() {
  if (typeof jQuery === 'undefined') return false;
  var v = jQuery.fn.jquery.split('.').map(Number);
  return !(v[0] < 1 || (v[0] === 1 && v[1] < 9) || (v[0] === 1 && v[1] === 9 && v[2] < 1) || v[0] > 3);
}
if (!jqueryVersionOk()) {
  console.error('jQuery version out of Bootstrap 3 range [1.9.1, 4)');
}

Type guard

function isSupportedJQueryForBootstrap3() {
  if (typeof jQuery === 'undefined') return false;
  var v = jQuery.fn.jquery.split('.').map(Number);
  return v[0] >= 1 && !(v[0] >= 4) && !(v[0] === 1 && v[1] < 9);
}

Try / catch

window.addEventListener('error', function (ev) {
  if (ev && /requires jQuery version/.test(ev.message || '')) {
    console.error('Pin jQuery to 1.9.1–3.x for Bootstrap 3, or upgrade Bootstrap to v5 for jQuery 4');
  }
}, true);

Prevention

When it happens

Trigger: Loading jQuery 1.8 or earlier; loading jQuery 4.x alongside Bootstrap 3.3.7; bundling upgrading jQuery without upgrading Bootstrap.

Common situations: Upgrading jQuery to 4 in a legacy app still on Bootstrap 3; very old jQuery shipped with a template; mixed CDN versions across pages.

Related errors


AI-assisted analysis of dotnet/AspNetCore.Docs@c67a80103a (2026-08-13). Data as JSON: /api/errors/7fd8508a673e7237. Report an issue: GitHub.