Tuesday, May 7, 2013

Load from local when CDN fails

<!--script>window.requirejs || document.write('<script src="js/lib/require/require.js?v=RELEASE_VERSION"><\/script>')</script-->

f (typeof requirejs === 'undefined') {
    document.write(unescape("%3Cscript src='js/lib/require/require.js?v=RELEASE_VERSION' type='text/javascript'%3E%3C/script%3E"));
}

RequireJS itself has fallback URLs support
requirejs.config({
    enforceDefine: true,
    paths: {
        jquery: [
            '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min',
            'js/lib/jquery/jquery-1.7.2.min'
        ]
    }
});

No comments:

Post a Comment