I'm having some trouble with requirejs, jquery and an embeddable widget that I've written. The widget is loaded via a javascript (that contains a minified version of jQuery).
The problem is that the host site is using requirejs and tries to load jquery. Somehow, requirejs seems to think that jquery is already loaded (because of the minified version in the loader script) and skips loading of jquery. It uses the version that is included by the loader script. This will (due to timing issues?) make the loading of bootstrap fail, because it cannot find jquery.
How can I get requirejs on the host site to load jquery anyway? Why is it affected by the version of jquery that is included by my embeddable widget?
The host site with reqiurejs and the script that loads the widget:
<body>
...
<script async="" src="http://example.com/WidgetLoaderScript.js"></script>
...
<script src="/Scripts/require.js"></script>
<script>
requirejs.config({
baseUrl: "../../Scripts",
paths: {
jquery: "jquery-1.10.2.min",
bootstrap: "bootstrap.min"
},
shim: {
bootstrap: {
deps: ["jquery"]
}
}
});
require(["jquery", "bootstrap"], function ($) {
// Do stuff
});
</script>
</body>
Part of the loader script:
(function (window, document, undefined) {
// Load minified version of jQuery
(function(e,t){var n,r,i ......;
var $abc = $.noConflict();
// Use $abc to append widget into host site
...
})(window, document);