JSFiddle - React, Tailwind, and code Playground

by Mark

JavaScript

function getScript(url, success) {
  var script = document.createElement('script');
  script.src = url;
  var head = document.getElementsByTagName('head')[0],
    done = false;
//success();

if (typeof (success) === "function") {
	success();
}

  script.onload = script.onreadystatechange = function() { // Attach handlers for all browsers
    if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
      done = true;
      success();
      script.onload = script.onreadystatechange = null;
      head.removeChild(script);
    };
  };
  head.appendChild(script);
}

function test() { alert("hey"); }

getScript("https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js", test);