Reputation: 9660
If the same Javascript file has different URL's then is it possible to find out that if the JavaScript file has already been downloaded. Not using the URL but using the name of the file.
Is this possible using JavaScript?
Upvotes: 1
Views: 170
Reputation: 2596
If you defined a variable in the script, you can check if the variable is already defined:
if (typeof(myScriptDefined) == "undefined") {
myScriptDefined=true;
// rest of my script content
}
Upvotes: 1
Reputation: 1109
You could find all <script>
elements in the DOM and check if any src
attributes match the regex of the filename.
Upvotes: 0