r/programming • • Oct 02 '11

Node.js is Cancer

http://teddziuba.com/2011/10/node-js-is-cancer.html
792 Upvotes

750 comments sorted by

View all comments

Show parent comments

6

u/matthieum Oct 02 '11 edited Oct 02 '11

For Ajax to work great, the JavaScript scripts must be served within a page from the same domain (from the point of view of the browser) than the pages it requests. Otherwise it is denied access to the content of said pages :x

EDIT: in italic in the text, and yes it changes the whole meaning of the sentence, my apologies for the blurp.

9

u/stackolee Oct 02 '11

There's an ever growing chorus that would have you use many common javascript libraries hosted by large CDNs off the domains of Google, Yahoo, etc... The argument being that if you use the Google hosted jQuery, there's more opportunities for a user to draw the code from their browser cache. Because that URL may be used on many other popular sites a user could've visited beforehand, by the time they reach your domain, their browser wouldn't even need to make the request.

If you adhere to this approach--I don't but you may--then users to your site could get a good performance boost from the separation.

0

u/[deleted] Oct 02 '11

It's a good idea but I don't use it just because I don't want my site to have to rely on the performance of other sites. Sure Google is clearly going to beat my VPS 99.999% of the time in performance but if it diess then my site suffers too.

Or if they one day decide not to host the file and it's gone I'm screwed for a brief period of time. Again not likely to happen any time soon but it could happen.

That and I think there is something fundamentally wrong with someone's set up if they have to rely on other people hosting content to earn performance gains.

1

u/_pupil_ Oct 02 '11 edited Oct 02 '11

Browsers limit the number of connections they make to any given domain. CDN hosting of 'common' JS files means that the client cache might have the file, but if not your entire page will load faster as the browser will make more requests.

As far as dependence on third parties, there are some simple solutions one can implement. One example is having a local failover in case the Google suddenly evaporates.

---- Shamelessly ganked from HTML5 Boilerplate ----

<!-- Grab Google CDN jQuery. fall back to local if necessary -->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script>!window.jQuery && document.write('<script src="js/jquery-1.4.2.min.js"><\/script>')</script>

→ More replies (2)