0

I know this package is deprecated but would like to understand what's going on -

Looking at the docs, does the below mean that if window.JSON is true, run the complete function? And if not, load up the nope file?

yepnope({
  test: window.JSON,
  nope: 'json2.js',
  complete: function () {
    var data = window.JSON.parse('{ "json" : "string" }');
  }
});
akantoword
  • 2,824
  • 8
  • 26
  • 43

1 Answers1

1

No, complete is a callback that is always called regardless of what happens when all (or even when nothing loads) the resources are loaded.

You will need a yep:

yepnope({
   test: window.JSON,
   yep: 'json1.js',
   nope: 'json2.js',
   complete: function () {
      alert('done');
   }
});

The example from their page you had copied is for loading a script ONLY when a test fails, and nothing when it passes.

Madness
  • 2,730
  • 3
  • 20
  • 29