{"record":{"id":"1670bc71fdff2154","repo":"dotnet/AspNetCore.Docs","slug":"bootstrap-s-javascript-requires-jquery-1670bc","errorCode":null,"errorMessage":"Bootstrap's JavaScript requires jQuery","messagePattern":"Bootstrap's JavaScript requires jQuery","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"aspnetcore/mvc/views/tag-helpers/th-components/samples/RazorPagesSample/wwwroot/lib/bootstrap/js/bootstrap.js","lineNumber":8,"sourceCode":"/*!\n * Bootstrap v3.3.7 (http://getbootstrap.com)\n * Copyright 2011-2016 Twitter, Inc.\n * Licensed under the MIT license\n */\n\nif (typeof jQuery === 'undefined') {\n  throw new Error('Bootstrap\\'s JavaScript requires jQuery')\n}\n\n+function ($) {\n  'use strict';\n  var version = $.fn.jquery.split(' ')[0].split('.')\n  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) {\n    throw new Error('Bootstrap\\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4')\n  }\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: transition.js v3.3.7\n * http://getbootstrap.com/javascript/#transitions\n * ========================================================================\n * Copyright 2011-2016 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/dotnet/AspNetCore.Docs/blob/c67a80103a1a74db20784debd919c7fdda96c510/aspnetcore/mvc/views/tag-helpers/th-components/samples/RazorPagesSample/wwwroot/lib/bootstrap/js/bootstrap.js#L1-L26","documentation":"Bootstrap 3.3.7's bootstrap.js throws at load time if `typeof jQuery === 'undefined'`. Bootstrap is a jQuery plugin and attaches its components to `$.fn`, so it cannot initialize without jQuery present on the global scope first.","triggerScenarios":"Loading bootstrap.js before jquery.js, or loading bootstrap.js in an environment where jQuery was never included. The check runs at script parse time, so the throw is immediate.","commonSituations":"Script bundle ordering wrong (bootstrap bundled before jquery); jQuery loaded via AMD/module while bootstrap expects a global; jQuery failed to load (404 on the CDN); bundler stripped jQuery as an unused dep.","solutions":["Ensure jQuery is included before Bootstrap: `<script src=\"lib/jquery/jquery.js\"></script>` then `<script src=\"lib/bootstrap/js/bootstrap.js\"></script>`.","Verify the jQuery file actually loads (check Network tab for 200, not 404).","If using a bundler, set the correct order in the bundle config and expose jQuery globally (`window.jQuery = window.$ = require('jquery')`).","Pin jQuery to a version in Bootstrap's supported range (1.9.1 – <4 for Bootstrap 3)."],"exampleFix":"<!-- before -->\n<script src=\"lib/bootstrap/js/bootstrap.js\"></script>\n<script src=\"lib/jquery/jquery.js\"></script>\n\n<!-- after -->\n<script src=\"lib/jquery/jquery.js\"></script>\n<script src=\"lib/bootstrap/js/bootstrap.js\"></script>","handlingStrategy":"validation","validationCode":"// In a bootstrap module loaded before anything else:\nif (typeof window.jQuery === 'undefined') {\n  throw new Error('Load jQuery before Bootstrap');\n}\nrequire('./bootstrap');","typeGuard":"function jQueryReady() {\n  return typeof window !== 'undefined' && typeof window.jQuery === 'function';\n}","tryCatchPattern":"// Not typically caught — load-order fix is the remedy.\n// Bundler-safe: import jquery first, assign globals, then bootstrap.\nimport jQuery from 'jquery';\nwindow.jQuery = window.$ = jQuery;\nrequire('bootstrap');","preventionTips":["Always order script tags: jQuery, then Bootstrap.","Pin matching versions of both libs in package.json/bower.json.","Verify jQuery is on the global scope in non-module setups."],"tags":["bootstrap","jquery","load-order","dependency"],"backgroundTag":null,"analyzedSha":"c67a80103a1a74db20784debd919c7fdda96c510","analyzedAt":"2026-08-13T17:46:11.763Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}