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?
Article source: http://css-tricks.com/13261-large-file-on-cdn-or-small-local/
No comments:
Post a Comment