JSFiddle - React, Tailwind, and code Playground
HTML
<!--- DON'T FORGET TO OPEN YOUR JAVASCRIPT CONSOLE! -->
<!-- message # 2 fires before message # 1, which is not what we want -->
<!-- blog.kevinchisholm.com -->
JavaScript
function getScript(){
//create a script element and inject it into the page
var script = document.createElement('script');
script.src = 'http://sub1.kevinchisholm.com/blog/examples/sleep1.php';
document.getElementsByTagName('head')[0].appendChild(script);
};
getScript();
console.log("2) the new script has been loaded"); //fires before the script finishes loading