Conflict With Other Libraries (Waypoints) when loading with RequireJs, Loads jquery twice
manikbajaj opened this issue · 0 comments
manikbajaj commented
Hi
I had an issue where jQuery was loading twice on the page because while defining your AMD module you have taken 'jQuery' as a dependency. I think instead of including it there it should only be a part of the documentation. This is what was happening in my case.
- I included jQuery globally because I was using bootstrap and also wanted to load jQuery in the global scope and not via RequireJs.
- Since in AMD it has been defined as a dependency even RequireJs was loading jQuery and it was loading twice on the page.
- I included Waypoints jQuery plugin which stopped working because of jQuery being included twice on the page.
Just to resolve this temporarily I have used the following configuration in require.config
require.config({
baseUrl: "/assets/js",
paths: {
circleProgress:'circle-progress',
jqueryWaypoints: 'jquery.waypoints',
},
shim: {
jqueryWaypoints: {
deps: ['circleProgress']
}
}
});
then in my module I have defined the module like this
define(['jqueryWaypoints'], function (){}
This does away with the error for now but jQuery still loads twice on the page where the module is being loaded. Let me know if you can think of an elegant solution to this.
Thanks!