Last active
August 29, 2015 14:03
-
-
Save edm00se/003b7306a949bf4b5ab6 to your computer and use it in GitHub Desktop.
AngularJS local fallback for Google CDN.
This file contains hidden or 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
<!-- attempt to load AngularJS from CDN --> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script> | |
<!-- if AngularJS fails to load fallback a local version --> | |
<script type="text/javascript"> | |
if(!window.angular){ | |
var ang = document.createElement('script'); | |
//exlpicit path to server library copy | |
ang.src = "//server.com/libs/angularjs/1.2.19/angular.min.js"; | |
// relative path | |
// ang.src = "/libs/angularjs/1.2.19/angular.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(ang); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment