Created
February 20, 2019 08:09
-
-
Save graphoarty/ea1757309d4420cfbe4f0b4dcfaff340 to your computer and use it in GitHub Desktop.
Import Asynchronous (async) JavaScript (js) Script in Reactjs
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
// Example Call | |
// asyncScript('https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'); | |
asyncScript = (scriptPath) => { | |
const script = document.createElement('script'); | |
script.src = scriptPath; | |
script.async = true; | |
document.body.appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment