From a489e6eaf0d9e5a2748717f193bf6ae7ff9d2ae7 Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Wed, 26 Aug 2026 13:17:37 -0300 Subject: [PATCH] Fix carousel and other Bootstrap JS plugins broken by jQuery noConflict order The sphinx_bootstrap_theme package loads scripts as: jquery, jquery-fix.js, bootstrap.min.js, bootstrap-sphinx.js. Its bundled jquery-fix.js calls jQuery.noConflict(true), which strips both window.jQuery and window.$ before bootstrap.min.js loads. bootstrap.min.js grabs the global jQuery symbol to attach its plugins, so it throws immediately and none of them (carousel, dropdown, collapse, ...) ever get attached. Override the theme's static jquery-fix.js (Sphinx lets project html_static_path files overwrite theme static files of the same name) to call noConflict() without removing window.jQuery, which keeps bootstrap.min.js working while bootstrap-sphinx.js still uses window.$jqTheme as before. Fixes GenericMappingTools/website#146 --- _static/js/jquery-fix.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 _static/js/jquery-fix.js diff --git a/_static/js/jquery-fix.js b/_static/js/jquery-fix.js new file mode 100644 index 0000000..44a4a49 --- /dev/null +++ b/_static/js/jquery-fix.js @@ -0,0 +1,15 @@ +// Override of sphinx_bootstrap_theme's bundled jquery-fix.js. +// +// The theme loads scripts in this order: jquery, jquery-fix.js, +// bootstrap.min.js, bootstrap-sphinx.js. The upstream jquery-fix.js calls +// jQuery.noConflict(true), which removes *both* window.jQuery and window.$ +// before bootstrap.min.js runs. bootstrap.min.js grabs the global `jQuery` +// symbol to attach its plugins (carousel, dropdown, collapse, ...), so it +// crashes immediately and none of them get attached - breaking, among other +// things, the front-page carousel (GenericMappingTools/website#146). +// +// Calling noConflict() without `true` only releases the `$` alias and keeps +// window.jQuery defined, so bootstrap.min.js still works. bootstrap-sphinx.js +// already prefers window.$jqTheme, so behavior for the theme's own script is +// unchanged. +window.$jqTheme = jQuery.noConflict();