jquery-circle-progress icon indicating copy to clipboard operation
jquery-circle-progress copied to clipboard

Conflict With Other Libraries (Waypoints) when loading with RequireJs, Loads jquery twice

Open manikbajaj opened this issue 6 years ago • 0 comments

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.

  1. I included jQuery globally because I was using bootstrap and also wanted to load jQuery in the global scope and not via RequireJs.
  2. Since in AMD it has been defined as a dependency even RequireJs was loading jQuery and it was loading twice on the page.
  3. 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!

manikbajaj avatar Jul 15 '19 13:07 manikbajaj