Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created May 5, 2015 13:25
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save AllThingsSmitty/889acd01889c84ff162c to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/889acd01889c84ff162c to your computer and use it in GitHub Desktop.
Check if any given script has loaded
var myScript = document.createElement('script');
myScript.src = 'http://code.jquery.com/jquery-2.1.4.min.js';
myScript.onload = function() {
console.log('jQuery loaded.');
};
document.body.appendChild(myScript);
@DutchKevv
Copy link

This doesn't check if any script is loaded, it just loads a script...

@schwabbthedeck
Copy link

Yeah, @DutchKevv is right, this loads the script. What it is doing though is executing that function when it is finished loading.

@alexlopez-natgeo
Copy link

This one duplicates when 2 instances of the same file try to load, you might want to try https://gist.github.com/alecsgone/b19cc0f45a76b1fbda31ba58a865d4a6

@hta218
Copy link

hta218 commented May 14, 2021

I wish I could found a down-vote button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment