Open rotatingJazz opened 10 years ago
Hey @rotatingJazz,
curl.js does something like this now, but only for a single module specified as the main
property of the config. If you specify a comma-separated list of ids, it will split the ids, use the first one as the primary id, and use the second item as the fallback. It sounds like that isn't sufficient for your needs, though.
The current solution is problematic since it can't tell the difference between 404s and syntax errors in a successfully loaded script. The matchString
idea is interesting, but it won't work because we can't access the text of a cross-origin script.
If you have any other ideas, please share.
Thanks!
-- John
What
If any file fails to properly load (see later on), load it from a different server.
Use case
I upload static files to github to increase load speed but sometimes github is down for a little while. That breaks user experience, because the page fails to load properly.
Edit: I just had an incident with Cloudflare 's cdnjs while trying to load the flot library, so it 's not just limited to the github case.
Proposal
Instead of passing a string for each file, let 's pass an array
Curl
would try loading the file found onfilepath
as usually, then assert it ends (without taking into account any whitespace) with thematchString
, and if it fails, try doing the same but this time using thefallbackPath
.Pros I see:
);
at the end would probably do the trick consistently.