New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fallback URL functionality #97
Conversation
Thanks for the PR. I understand how the implementation works, but could use a little convincing of the use-case :) If you're working on an app where you have control of the locally served files, wouldn't there be a low chance of a script not being available? Any extra details would be useful :) |
I like to take advantage of public CDNs where possible, to improve loading times and reduce load on my servers; for example, I use googleapis for AngularJS and cdnjs for jQuery. I also serve the application JS files through MaxCDN. But I also have copies of those libraries on my site with fallback code if the CDN is unavailable. I want to use Basket.js as an additional optimization, but I'd still like to use the CDNs for the initial download of those files, and have the fallback functionality. And the cross-site thing isn't an issue in my case because my application requires a CORS-compatible browser anyway. |
@@ -44,6 +44,9 @@ | |||
}; | |||
|
|||
var getUrl = function( url ) { | |||
if (url instanceof Array) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.isArray()
👍 while i don't see the use myself, i know a lot of people that uses CDN with local fallback. @markrendle can you add some docs? |
@markrendle ping :) |
Sorry, missed this. Will add some docs. |
ping :) |
1 similar comment
ping :) |
Closing for lack of response. |
This change allows an array of URLs to be passed for a script, where if the first URL fails the loader will try the next, and so on, similar to the Require.js feature. I noticed that on the Basket.js homepage it says that only same-origin URIs are supported, but the XHR approach will work fine with modern browsers and most CDNs allow an Access-Control-Allow-Origin wildcard, so I think this adds value.