I use yepnope.js as a resource loaded. I want to execute code in my JS module only when all the dependencies for that module have been loaded. I do not want to load JS dependencies that already been loaded.
Suppose, I have dependencies D1.js and D2.js. I tried
yepnope({
load: ['D1.js', 'D2.js],
complete: function() {
//execute my code here
}
});
That works, but, resources are loaded every time, even if they were already loaded before.
If I do multiple tests like that:
yepnope([{
test: $().d1,
nope: 'D1.js'
},
{
test: $().d2,
nope: 'D2.js'
}]);
It's not clear where to put the overall completed function -- the one that runs after all the resources have been loaded.
Is it possible to do this with yepnope, or do I need to use a different component?
Thanks.
The callbacks are run after the corresponding scripts are executed (not just loaded). All the scripts run in order, so if you put a callback
or a complete
property on the last object, it'll run last.