YepNope
http://yepnopejs.com/
Modernizr
http://modernizr.com/
Se estiver usando Modernizr e / ou Yepnope, você pode usar este método para carregar sua biblioteca favorita do CDN e retornar para sua versão local se o carregamento inicial falhar.
//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');
});
}
}
]);