2

When a required script doesn't load, the callback fires even if the script load fails (404):

function callback () {
    console.log('callback,', arguments);
}

head.test({
    test: 1 === 1,
    success: ["/non-existant.js"], 
    failure: [],
    callback: callback
});

In the above example, the console outputs this regardless of whether or not the script file is loaded:

callback, []

Is there a way to handle that?

Russ Back
  • 903
  • 2
  • 15
  • 27

1 Answers1

0

If you want to know what file was loaded, than you always know it via your test condition. But, if you seeking that if your /non-existant.js file fails to load than your failure scripts should load than you are getting this test function wrong.

iMatoria
  • 1,450
  • 2
  • 19
  • 35
  • the test is to decide if the script should be loaded, what I'm looking for is a way to test if the defined script actually failed to load. Other than by testing the presence of some object that exists in the loaded file, it seems there is no inbuilt way to handle file IO errors – Russ Back Oct 02 '14 at 07:12