I\'m dynamically loading jQuery
and jQuery UI
into a page, and I need to know when jQuery UI
has successfully extended jQuery
I think this will do exactly what you need, add more dependency as much as you like.
(function () {
function getScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0];
var completed = false;
script.onload = script.onreadystatechange = function () {
if (!completed && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
completed = true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
}
getScript("Scripts/jquery-1.6.1.js", function () {
getScript("Scripts/jquery-ui-1.8.11.js", function () {
alert($.ui);
});
});
})();
Tested with IE7, IE8, IE9, Firefox, Safari, Chrome and Opera