Given thatCDNs are a Good Thing because they can serve resources closer to the client, the client can cache them, and you can reduce load on your own server.In recent browsers, loading resources from third-party servers does not decrease security thanks to Subresource Integrity (SRI).CDNs may be down or blocked in some countries, and are not available when developing offline1.I think it is compelling to use CDNs, but also to be prepared for them to be unavailable. This blog post gives a nice introduction to different approaches for providing fallbacks. If you look at the Basic example, you can see that it already contains quite a bit of boilerplate code to provide fallbacks for just jQuery and Bootstrap, while the favored solution suggests using Fallback.js, which seems to be largely unmaintained for the past year. Similarly, the most relevant SO question for the topic is only about providing a fallback for jQuery.However, in most real-world projects, I would expect to have 5 or more js/css resources, so I feel like you shouldn't have to repeat some messy boilerplate to provide fallbacks for all of them. Furthermore, every time you add or update a resource, you now have toUpdate the CDN linkUpdate the local fallback copy by manual download or changing version in npm/bower configUpdate the link to the fallbackUpdate the SRI hashWhereas in the Ideal World, I would expect to add/update the resource in one configuration file, and have all the other steps execute automatically (and then run tests to see if the update broke anything).Is there already an established workflow to achieve this?Or are CDNs, and especially SRI, still too recent?Or do most people simply not care to provide fallbacks for CDN resources?1. Although you could have a dev build that doesn't rely on CDNs, but I also consider that a form of fallback, since it also needs to be maintained.
Providing Local JS and CSS Resources for CDN Fallbacks
javascript;css;cdn