New Poll: Large file on CDN or small file local?

Avatar of Chris Coyier
Chris Coyier on (Updated on )

📣 Freelancers, Developers, and Part-Time Agency Owners: Kickstart Your Own Digital Agency with UACADEMY Launch by UGURUS 📣

The new poll is up (in the sidebar on the actual site, RSS folks) and it reads:

Would you rather host a 200k file on a major CDN or a 20k file self-hosted?

This requires a little explanation. Let’s say the file in question is jQuery UI. On your site, you only need it for it’s tabs functionality. You could load a copy of it from Google’s CDN like this:

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>

That file is literally 205k, because it’s the complete jQuery UI library. But, it’s on what is probably the world’s biggest/fastest/most-used CDN (Content Delivery Network). Lots of sites use jQuery UI and probably get it from there, so you have a decent chance of that file already being cached when a user gets to your site.

Or, you could download a customized copy of jQuery UI.

<script src="/js/jquery-ui-1.8.14.custom.min.js"></script>

This file could only be 20k, because it is trimmed down to only have the necessary stuff to make the tabs functionality work. That file is ten times smaller, but the chances of it being cached for a user coming to your site is nil if they are a first time visitor.

So all other things being equal, which do you choose?