Should Github be used as a CDN for javascript libraries? [closed]

You should not do that for JavaScript files if you care about performance or IE9 compatibility.

GitHub doesn’t serve its “raw” files with a far-future expires header. Without the possibility of cross-site caching, you lose the biggest benefit of using a public CDN to host your JavaScript. In fact, using GitHub as a CDN will be slower than simply hosting the files on your own server after each user’s first request for the file (assuming you configure caching correctly on your server).

Another problem is that GitHub doesn’t serve “raw” files with a content-type header that matches the file’s actual MIME type. In IE9 (and perhaps other browsers/proxies/firewalls/etc), JavaScript files that aren’t served with the correct content-type are blocked by default. You can see that in action on the BlockUI demo page, for example:

enter image description here

Leave a Comment