Let\'s face it, jQuery/jQuery-ui is a heavy download.
Google recommends deferred loading of JavaScript to speed up initial rendering. My page uses jQuery to set up s
In certain situation you could fire an event when jquery is loaded.
Then wrap your dependencies in a function:
// myscript1.js
(function(){
function initMyjQueryDependency() {
console.log('my code is executed after jquery is loaded!');
// here my code that depends on jquery
}
if ( jQueryHasLoaded === true )
initMyjQueryDependency();
else
document.body.addEventListener('jqueryloaded', initMyjQueryDependency, false);
}());
If jquery finishes to load after the other scripts, your dependencies will be executed when the jqueryloaded event is fired.
If jquery is already loaded, jQueryHasLoaded === true, your dependency will be executed initMyjQueryDependency().