I had a similar problem and solved it this way.
I added a label method using mixin to load resources at runtime, and I call it before starting, passing a list of css and js files.
It uses the getScript jQuery function.
loadResources(css, js, callback){
for(var i = 0; i < css.length; i++){
if(css[i] !== ''){
var link = document.createElement('link');
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("href", css[i]);
document.getElementsByTagName("head")[0].appendChild(link);
}
}
var jsProgress = 0;
for(var j = 0; j < js.length; j++){
$.getScript(js[j], function () {
if (++jsProgress == js.length && typeof callback !== 'undefined') callback();
});
}
}
source
share