Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to utilize jQuery-UI theme on CDN with local fallback?

Tags:

css

cdn

jquery-ui

Is there anyway to load jQuery-UI theme from CDN, but with local fallback? Similar to the javascript fall-back outline here? Google Hosted CDN with fall back

like image 993
BlueFox Avatar asked Sep 23 '10 21:09

BlueFox


1 Answers

I would recommend using the resource loader yepnope:

yepnope([{
  load: 'http:/­/ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js',
  complete: function () {
    if ( !window.jQuery ) {
      yepnope('local/jquery.min.js');
    }
  }
}, {
  load: 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js',
  complete: function () {
    if ( !window.jQuery.ui ) {
      yepnope('local/jquery-ui.min.js');
    }
  }
}]);

This will first try to load jQuery with local fallback, then load jQUery UI with local fallback.

like image 95
Sindre Sorhus Avatar answered Sep 21 '22 22:09

Sindre Sorhus