Closed szepeviktor closed 10 years ago
anything like this? http://requirejs.org/docs/api.html#pathsfallbacks
Hello @szepeviktor!
This seems like a useful feature and easy to add via an add-on loader. However, I would implement it differently from RequireJS. What are your thoughts about the following configuration?
curl.config({
paths: {
jquery: {
location: '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min',
config: { loader: 'curl/loader/fallback', fallback: 'jquery.min' }
}
}
});
-- John
Thank you very much! I would add these cases to this issue:
Basicly decide what to load based on a condition.
Is it possible to build in this loader?
Hey @szepeviktor,
Sniffing the environment and then deciding which library to load seems a bit much for a loader, imho. You could create a wrapper module for this, though. Something like this:
// "jquery" module
(function (moduleId) {
// wrap / passthru of actual jquery that is chosen
define([moduleId], function (jquery) { return jquery; });
}(
// do some feature sniffing here
document.addEventListener ? '//cdn.jquery.com/jquery2.1.1.min' : '//cdn.jquery.com/jquery1.9.1.min'
));
How does that look to you?
-- John
It seems to be solved.
How do I fall back to local version? It has a different name and all dependecies will fail.