Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also, you shouldn't be serving your content from a cdn anyway. All of your js files should be compressed into one file, browser cached, and gzipped.


Making the file smaller doesn't reduce latency. The point of a CDN is local distribution, not just load balancing. You also get to share a cache with other sites; if you point to jQuery on Google's CDN, and the visitor has been to any other site using that CDN, they already have the file cached.


>> Making the file smaller doesn't reduce latency

No, but I think the parent was making the case for combining everything into a single file (jQuery + app) which has benefits in reducing number of HTTP requests, especially important on mobile for example.

>> The point of a CDN is local distribution, not just load balancing.

Personally, I build web-apps for UK customers, and host in the UK, so this is a non-issue. I suspect the same is true for a lot of people building complex web-apps (i.e. apps complex enough that you should care about your build process).

>> You also get to share a cache with other sites; if you point to jQuery on Google's CDN, and the visitor has been to any other site using that CDN, they already have the file cached.

Not really true, they have to have hit another site that has uses that exact version of jQuery in order to have it cached. There was a study done recently that illustrated this was very unlikely. I wish I could link to it, but all I can tell you is Alex Sexton referenced it on the Shoptalk podcast [1].

Edit: Another commenter has now referenced the survey in question [2].

[1] http://shoptalkshow.com/episodes/061-with-alex-sexton/

[2] http://www.stevesouders.com/blog/2013/03/18/http-archive-jqu...


This advice breaks if you have more than one type of page on your site: you don't want to have browsers processing tons of JS which isn't needed for the current page, especially on mobile. Even if it's always cached (not even remotely true), there's a non-trivial amount of parser overhead and memory usage.

What I prefer to do is have a common bundle for the JS used on every page, bundles for each distinct type of page, and separate polyfills for old browsers. This improves your initial cold-cache load time for every page, avoids penalizing new browsers because other people use antique browsers and avoids cache churn by invalidating the entire bundle every time you change anything in one JS file.


> All of your js files should be compressed into one file, browser cached, and gzipped.

And then, served via CDN.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: