-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: fallback CDN #23
Comments
This would be a better way as it would virtually handles all types of resources, not only JavaScript: var fallbackUrls = {
'https://unpkg.com/[email protected]/dist/react.js': 'https://cdn.jsdelivr.net/npm/[email protected]/dist/react.min.js'
};
window.addEventListener('error', function(e) {
var failedUrl = e.target.src || e.target.href
if (failedUrl in fallbackUrls) {
if (isJs) {
document.write('<script src="https://unpkg.com/[email protected]/dist/react.js"><\/script>');
} else { ... }
}
}, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by jso0/html-webpack-cdn-plugin#1
Depends on #13
options.fallbackResolver
Type:
string
||function
Default:
'module-to-cdn' || 'module-to-jsdelivr'
Similar to
resolver
but the module will be loaded from this CDN only if the main CDN is experiencing issuesIt will create a new file which will contains for each module:
window.React || document.write('<script src="https://unpkg.com/[email protected]/dist/react.js"><\/script>');
NOTE:
resolver
andfallback
must both return a validcdnConfig
otherwise the module is ignoredThe text was updated successfully, but these errors were encountered: