diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js index cb402055f..0641e368e 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js @@ -1,7 +1,12 @@ (function (factory) { if (typeof define === 'function' && define.amd) { - // AMD. Register as anonymous module. - define(['jquery'], factory); + if (typeof require === 'function') { + // RequireJS, use jQuery from its config + require(['jquery'], factory); + } else { + // AMD, but not RequireJS. Register as anonymous module. + define(['jquery'], factory); + } } else { // Browser globals. window.djdt = factory(jQuery); diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js index 172c2a6a4..908b41c06 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js @@ -1,6 +1,12 @@ (function (factory) { if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); + if (typeof require === 'function') { + // RequireJS, use jQuery from its config + require(['jquery'], factory); + } else { + // AMD, but not RequireJS. Register as anonymous module. + define(['jquery'], factory); + } } else { factory(jQuery); } diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js index c554bceea..ee2cb1ce4 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js @@ -1,6 +1,12 @@ (function (factory) { if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); + if (typeof require === 'function') { + // RequireJS, use jQuery from its config + require(['jquery'], factory); + } else { + // AMD, but not RequireJS. Register as anonymous module. + define(['jquery'], factory); + } } else { factory(jQuery); } diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.template.js b/debug_toolbar/static/debug_toolbar/js/toolbar.template.js index 62408982c..9a9da7307 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.template.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.template.js @@ -1,6 +1,12 @@ (function (factory) { if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); + if (typeof require === 'function') { + // RequireJS, use jQuery from its config + require(['jquery'], factory); + } else { + // AMD, but not RequireJS. Register as anonymous module. + define(['jquery'], factory); + } } else { factory(jQuery); } diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js index 514fda7ef..ce471e29b 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js @@ -1,6 +1,12 @@ (function (factory) { if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); + if (typeof require === 'function') { + // RequireJS, use jQuery from its config + require(['jquery'], factory); + } else { + // AMD, but not RequireJS. Register as anonymous module. + define(['jquery'], factory); + } } else { factory(jQuery); }