Skip to content

Instantly share code, notes, and snippets.

@englishextra
Last active October 1, 2016 19:34
Show Gist options
  • Save englishextra/403a0ca44fc5f495400ed0e20bc51d47 to your computer and use it in GitHub Desktop.
Save englishextra/403a0ca44fc5f495400ed0e20bc51d47 to your computer and use it in GitHub Desktop.
How can I check if a JS file has been included already?
/*!
* How can I check if a JS file has been included already?
* gist.github.com/englishextra/403a0ca44fc5f495400ed0e20bc51d47
* stackoverflow.com/questions/18155347/how-can-i-check-if-a-js-file-has-been-included-already
* @param {String} s path string
* scriptIsLoaded(s)
*/
var scriptIsLoaded=function(s){for(var b=document.getElementsByTagName("script")||"",a=0;a<b.length;a++)if(b[a].getAttribute("src")==s)return!0;return!1};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment