This has been moved to an official Git repository
Last active
December 19, 2015 10:29
-
-
Save kentcdodds/5941149 to your computer and use it in GitHub Desktop.
How to check whether an external resource loaded and load a local copy if it failed to load. See README.md
@klamping, thanks for the feedback. I'll look into the timeout concept a little. But I believe that the browser waits for each script to load/fail before moving on to parsing the rest of the document (hence the "best practice" of including scripts at the bottom of your page right before the tag).
Note to self Figure out a way to add an option for libraries that attach themselves to the namespace of other global variables (like jQuery plugins or AngularJS modules).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the code looks really clean. As a suggestion, I'd consider allowing a timeout method to be added, to give the CDN just a little bit of time to load the script before bailing out to the local copy. Also, I assume that removing the script stops the CDN version from loading? Good stuff.