Javascript script load order - undefined function
I am working in a not very nice template that made me load some scripts with JS as I have no control over the order there. I am trying to load a library, but when I try to call it I get an undefined error.
$.getScript( "js/velocity.min.js").done(function(){
$('body').velocity({ width: 200})
});
Get error: Unacceptable TypeError: $ (...). speed is not a function
How can it be? I just downloaded you!
Well there was a conflict with another script that needs to be loaded, to fix this, I wrap the speed code in a closure and set "define" to null inside it.
(function($){
var define = null;
//then velocity code is here
})(jQuery)
+3
source to share