Skip to content

Instantly share code, notes, and snippets.

@mangreen
Last active August 29, 2015 14:14
Show Gist options
  • Save mangreen/70a1ba06890169ab5b6d to your computer and use it in GitHub Desktop.
Save mangreen/70a1ba06890169ab5b6d to your computer and use it in GitHub Desktop.
JavaScript: Falling back to a local version of AngularJS if the CDN version fails to load
<!-- attempt to load AngularJS from CDN -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<!-- if AngularJS fails to load fallback a local version -->
<script>window.angular || document.write('<script src="assets/js/angular.min.js"><\/script>');</script>
<!-- jQuery Ver. -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
window.jQuery || document.write('<script src="../components/jquery/dist/jquery.min.js"><\/script>')
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment