Last active
June 2, 2023 15:42
-
-
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
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
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