JSFiddle - React, Tailwind, and code Playground
by cancerbero_sgx
JavaScript
var _loadF = function(name, type, listener) {
var el = null;
if (type == "js") {
el = document.createElement("script");
el.setAttribute("type", "text/javascript");
if (listener) {
el.onreadystatechange = function() {
if (this.readyState == 'complete')
listener();
};
el.onload = listener;
}
el.setAttribute("src", name);
} else if (type == "css") {
el = document.createElement("link");
el.setAttribute("rel", "stylesheet");
el.setAttribute("type", "text/css");
el.setAttribute("href", name);
}
document.body.appendChild(el);
}
//An example usage:
_loadF("http://code.jquery.com/jquery-2.0.0.min.js", "js", function(){
//jquery loaded to current DOM window and ready to use
$("p").click(function(e){
alert("p clicked");
});
});
console.log('end')