I\'m using the following bit of script to load another one:
$.getScript(\"CAGScript.js\", function () {
try {
CAGinit();
} catch(err) {
In order to make sure CAGScript.js is LOADED and EXECUTED before calling CAGinit function, the surest way is to have the function call inside CAGScript.js.
CAGScript.js:
...
/*
your code
*/
function CAGinit(){
...
}
...
/* last line */
CAGinit();
and then, in your main file just call getScript():
$.getScript("CAGScript.js");