You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
[ filePath, matchString, fallbackPath ]
Curl would try loading the file found on filepath as usually, then assert it ends (without taking into account any whitespace) with the matchString, and if it fails, try doing the same but this time using the fallbackPath.
Pros I see:
We bypass the "404 not reported properly" IE issue
We make sure we load js code and not some "Oops, not found" page
By matching at the end and not accounting for whitespace, we don't have to worry for any transparent minifications some CDNs (or deployment tools) do (e.g. a file starts with a comment and it gets removed). Matching with something like ); at the end would probably do the trick consistently.
No practical speed penalty considerations
The text was updated successfully, but these errors were encountered:
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.
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.The text was updated successfully, but these errors were encountered: