Skip to content

Instantly share code, notes, and snippets.

@floydnoel
Last active June 2, 2023 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floydnoel/2ee8282d1aca776e5bfca916970550ba to your computer and use it in GitHub Desktop.
Save floydnoel/2ee8282d1aca776e5bfca916970550ba to your computer and use it in GitHub Desktop.
Check if a given script has been loaded already on a page, by url string. Inspired by https://stackoverflow.com/questions/47088181/how-to-use-tesseract-js-in-a-react-app and https://github.com/facebook/react/issues/4670
const scriptAlreadyLoaded = urlString => Array.prototype.slice.call(document.scripts).filter(s => s.src).map(s => s.src).contains(urlString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment