I am trying to use yepnope for handling fallback for public CDN.
Example code:
yepnope([
{
load: [
'http://tinymce.cachefly.net/4.0/tinymce.min.js'
],
complete: function(){
if (typeof(tinymce) === 'undefined') {
yepnope('/js/tinymce.min.js');
};
tinymce.init({selector:'textarea'});
}
}
]);
The code is basically working. When the public CDN fails, it will load the local script. But the problem is, it does not wait for the local script to load and continue with execution. In this example code, it runs tinymce.init({selector:'textarea'}); before local tinymce script is loaded.
How can I solve it? Thank you.
yepnopeis asynchronous, anything that has to wait for loading has to be done in thecompleteoption.