Skip to Main Content
Node for Front-End Developers
book

Node for Front-End Developers

by Garann Means
January 2012
Beginner content levelBeginner
60 pages
1h 18m
English
O'Reilly Media, Inc.
Content preview from Node for Front-End Developers

Real-Time Communication

When Ajax showed up, it ushered in a new way of thinking about web requests. It was no longer necessary to request entire pages—we could communicate with the server in pure data. The server still had to wait for requests from the client, however. A client could poll the server for updates, but there was no way for the server to push new information to the client. The WebSockets API is part of the large collection of new standards being developed under the name HTML5, and allows the server and the client to open a bidirectional connection so that data can be pushed back and forth whenever necessary.

WebSockets and the various fallbacks used to mimic them aren’t a technology specific to Node, but they make a very tidy fit. WebSockets are controlled with JavaScript, and the way they work looks an awful lot like the type of event handling we’re used to in JavaScript. As we move toward applications that anticipate users’ needs, perform non-essential operations in the background and report status, or just offer users a window into what’s happening on the server as it happens, WebSockets become increasingly necessary. One or two real-time features might be easy enough to handle with long polling or some other method, but an entire real-time application warrants the use of the only truly appropriate technology.

One of the more popular and mature Node modules is Socket.IO, which wraps up WebSockets and a selection of fallbacks and exposes the functionality via an API ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Website Performance: Optimizing the Front-End and Back-End

Professional Website Performance: Optimizing the Front-End and Back-End

Peter Smith
Redux Quick Start Guide

Redux Quick Start Guide

James Lee, Tao Wei, Suresh Kumar Mukhiya

Publisher Resources

ISBN: 9781449329112Errata PageSupplemental Content