I\'m using the following bit of script to load another one:
$.getScript(\"CAGScript.js\", function () {
try {
CAGinit();
} catch(err) {
Yeah, I've discovered too that getScript is unreliable in FireFox, firing the callback before the script has been downloaded and/or executed. (Using JQuery 1.41 & FireFox 3.6. Issue doesn't seem to afflict IE, Chrome or Opera.)
I haven't done extensive testing, but it seems to only happen with some specific scripts...not sure why.
RaYell's suggestion doesn't work, as getScript will report success even though the script has not yet been eval'ed. Pieter's suggestion in most cases causes the code to be eval'ed twice, which is inefficient and can cause errors.
This alternative seems to work where getScript does not. Note that it seems to be adding a SCRIPT DOM element, whereas getScript does XHR.
http://www.diveintojavascript.com/projects/sidjs-load-javascript-and-stylesheets-on-demand