You canTo check if the javascript in nonexistant.js
returned no error you have to add a variable inside http://fail.org/nonexistant.js
like var isExecuted = true;
and then check if it exists when the script tag is loaded:.
However if you only want to check that the nonexistant.js
returned without a 404 (meaning it exists), you can try with a isLoaded
variable ...
var isExecuted = false;
var isLoaded = false;
script_tag.onload = script_tag.onreadystatechange = function() {
if(!this.readyState ||
this.readyState == "loaded" || this.readyState == "complete") {
// script successfully loaded
isLoaded = true;
if(isExecuted) // no error
}
}
This will cover both cases.