I need to append the css and js file dynamically and am using below method
document.getElementsByTagName('head')[0].appendChild();
this method doesn't allow second parameter. I have to append both the css and js file dynamically. I am calling the above method twice to append the files. Any other generic way to restrict the above method to be called only once.
Here it is what i have tried:
var jscss = function(cp, sp){
var css = document.createElement("link");
css.setAttribute("rel", "stylesheet");
css.setAttribute("type", "text/css");
css.setAttribute("href", cp);
document.getElementsByTagName('head')[0].appendChild(css);
var script = document.createElement('script');
script.src = sp;
document.getElementsByTagName('head')[0].appendChild(script);
};
jscss();