JSFiddle - React, Tailwind, and code Playground

by moob

JavaScript

function stunn_import(filePath){   
    var failAfter = 3000,
        success = function(){clearTimeout(t);console.log("stunn_import("+ script.src + ")");},
        error = function(){alert("Unable to load "+ script.src);},
        t = setTimeout(error,failAfter);    
    
    var script = document.createElement('script');
        script.src = filePath;
        script.type = 'text/javascript';
        script.onreadystatechange = success;
        script.onload = success;
    
    var head = document.getElementsByTagName('head')[0];
        head.appendChild(script);

}
stunn_import("/path/to/script.js");
//stunn_import("/js/beautifier.js");