Created
June 3, 2020 01:55
-
-
Save xantiagoma/9e31d058f2068e468d31de81dda6c83f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScript(url) { | |
return new Promise(function (resolve, reject) { | |
try { | |
function callback() { | |
resolve(url); | |
} | |
var s = document.createElement("script"); | |
s.src = url; | |
if (s.addEventListener) { | |
s.addEventListener("load", callback, false); | |
} else if (s.readyState) { | |
s.onreadystatechange = callback; | |
} | |
document.body.appendChild(s); | |
} catch (e) { | |
reject(e); | |
} | |
}); | |
} | |
(async function () { | |
const loadReact = await loadScript( | |
"https://unpkg.com/react@16/umd/react.development.js" | |
); | |
const loadReactDOM = await loadScript( | |
"https://unpkg.com/react-dom@16/umd/react-dom.development.js" | |
); | |
console.log("React loaded", React); | |
window.React = React; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment