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
Asked
Active
Viewed 1,184 times
7
-
1We're all getting paranoid here, aren't we? ;) – Yi Jiang Sep 23 '10 at 23:31
-
lol Yi Jiang that's the same thing you said when I asked about the YUI cdn. – stevebot Sep 24 '10 at 02:24
-
Well, allowing jquery-ui to fall-back is only half of the battle since the theme is also an integral part of the library. – BlueFox Sep 24 '10 at 05:05
-
I don't think this is paranoid - the googlecode cdn for jquery-ui css isn't serving the css for us right now, even though the jquery *is* being served. – cori Oct 28 '10 at 14:08
-
1Ugh, what's this then? http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css – BlueFox Oct 30 '10 at 02:18
-
Its not paranoid to want a fallback. The fallback guarantees that dialogs and autocompletes still work, if the machine has trouble accessing other parts of the internet (or if your on a plane with no WiFi!) – enorl76 May 17 '12 at 15:14
1 Answers
4
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.

Sindre Sorhus
- 62,972
- 39
- 168
- 232
-
2Although the answer did not specified, yepnope also supports loading of CSS, not just js, which will allow loading the complete jQuery UI package (including the CSS) with fallback! – BlueFox Jan 24 '12 at 13:44
-