Hanselman on CDN Fallbacks

CDNs fail, but your scripts don’t have to – fallback from CDN to local jQuery:

Even better, RequireJS has a really cool shorthand for fallback URLs which makes me smile:

    enforceDefine: true,
    paths: {
        jquery: [
            //If the CDN location fails, load from this location
require(['jquery'], function ($) {

With RequireJS you can then setup dependencies between modules as well and it will take care of the details.

Good insight on potential CDN problems, and great mitigation plan.


One thought on “Hanselman on CDN Fallbacks

  1. Pingback: Neither HTTP nor HTTPS | Do You Compute?

Comments are closed.