Skip to content

Instantly share code, notes, and snippets.

@graphoarty
Created February 20, 2019 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphoarty/ea1757309d4420cfbe4f0b4dcfaff340 to your computer and use it in GitHub Desktop.
Save graphoarty/ea1757309d4420cfbe4f0b4dcfaff340 to your computer and use it in GitHub Desktop.
Import Asynchronous (async) JavaScript (js) Script in Reactjs
// 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