dotnet/AspNetCore.Docs · critical · 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

Bootstrap 3.3.7 splits `$.fn.jquery` and throws if the version is below 1.9.1 or 4+. Bootstrap 3's components rely on jQuery APIs introduced by 1.9.1 and removed/changed in jQuery 4.

Source

Thrown at aspnetcore/mvc/views/tag-helpers/th-components/samples/RazorPagesSample/wwwroot/lib/bootstrap/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 [1.9.1, 4.0) — for Bootstrap 3.3.7, jQuery 1.12 or 2.2 or 3.x are safe.
  2. Upgrade Bootstrap to v4/v5 if you need jQuery 4 (or Bootstrap 5 which dropped jQuery entirely).
  3. Confirm only one jQuery loads — check `$.fn.jquery` in the console matches the intended version.
  4. Re-vendor the matching jQuery alongside bootstrap in the project (this sample ships lib/jquery/jquery.js).

Example fix

<!-- before: jQuery 4 with Bootstrap 3 -->
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>

<!-- after: jQuery 3.7 with Bootstrap 3.3.7 -->
<script src="lib/jquery/jquery.js"></script>
Defensive patterns

Strategy: validation

Validate before calling

function assertJQueryVersion() {
  var v = $.fn.jquery.split('.').map(Number);
  var ok = (v[0] > 1 || (v[0] === 1 && v[1] >= 9 && (v[1] > 9 || v[2] >= 1))) && v[0] < 4;
  if (!ok) throw new Error('jQuery ' + $.fn.jquery + ' incompatible with Bootstrap 3');
}

Type guard

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

Try / catch

// Version mismatch throws at load — fix the dependency rather than catch.
// For build-time guard:
try { require('bootstrap'); }
catch (e) { throw new Error('Resolve jQuery version first: ' + e.message); }

Prevention

When it happens

Trigger: Loading jQuery 1.8 or earlier, or jQuery 4.0+, then bootstrap.js. The version check at the top of bootstrap.js parses the version string and throws.

Common situations: Upgrading jQuery to 3.x or 4.x without re-checking Bootstrap compatibility; mixing a newer jQuery from a CDN with an old vendored Bootstrap; multiple jQuery versions where the global is the wrong one.

Related errors


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