Skip to content

Instantly share code, notes, and snippets.

@wochap
Created May 3, 2018 15:32
Show Gist options
  • Save wochap/0030ce1518e6f3b1fc9a18463fee9a98 to your computer and use it in GitHub Desktop.
Save wochap/0030ce1518e6f3b1fc9a18463fee9a98 to your computer and use it in GitHub Desktop.
// getScript({ url, id }) {
// return new Promise(resolve => {
// const head = document.getElementsByTagName("head")[0];
// const script = document.createElement("script");
// let done = false;
// script.src = url;
// if (id) {
// script.id = id;
// }
// // attach handlers for all browsers
// script.onload = script.onreadystatechange = function () {
// if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
// done = true;
// if (typeof success === "function") {
// resolve(script);
// }
// }
// };
// head.appendChild(script);
// });
// },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment