Created
January 8, 2014 22:44
-
-
Save albertpak/8325964 to your computer and use it in GitHub Desktop.
YepNope http://yepnopejs.com/ Modernizr http://modernizr.com/ If you are using Modernizr and/or Yepnope, you can use this method to load your favorite library from the CDN and fall-back to your local version if the initial load fails. Src: https://coderwall.com/p/pmx_4w
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
| //Load | |
| yepnope([ | |
| { | |
| load: [ | |
| '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', | |
| '//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js', | |
| '//cdnjs.cloudflare.com/ajax/libs/raphael/1.5.2/raphael-min.js' | |
| ], | |
| complete: function(){ | |
| if ( !window.jQuery ) { | |
| console.log('CDN Failed - Loading local version of jQuery.'); | |
| yepnope('assets/js/libs/jquery-1.7.2-min.js'); | |
| }; | |
| if ( !window.swfobject ) { | |
| console.log('CDN Failed - Loading local version of SWFObject.'); | |
| yepnope('assets/js/libs/swfobject-2.2-min.js'); | |
| }; | |
| if ( !window.Raphael ) { | |
| console.log('CDN Failed - Loading local version of Raphael.'); | |
| yepnope('assets/js/libs/raphael-1.5.2-min.js'); | |
| }; | |
| } | |
| }, | |
| { | |
| load: [ | |
| 'assets/js/file-one.js', | |
| 'assets/js/file-two.js' | |
| ], | |
| complete: function(){ | |
| //Loaded | |
| console.log('Primary JS Loaded'); | |
| //Ready | |
| $(function(){ | |
| console.log('DOM Ready'); | |
| }); | |
| } | |
| } | |
| ]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment