I\'m using the following bit of script to load another one:
$.getScript(\"CAGScript.js\", function () {
try {
CAGinit();
} catch(err) {
I wanted to have something similar to auto_load in PHP implemented in JS, the typical solution is using try-catch on all functions.. when the function is missing we jump to downloading its library.. My solution is taken from Pieter solution as follows:
function CheckUserPW(username,password){
try{
loginCheckUserPW(username,password);
} catch(err) {
$.getScript('login.js', function(xhr){
eval(xhr);
loginCheckUserPW(username,password);
});
}
}