AboutBlogContact
Web DevelopmentDecember 22, 2009 2 min read 70Updated: May 3, 2026

WebSockets (HyBi): The End of Cometing and Polling?

AunimedaAunimeda
📋 Table of Contents

WebSockets (HyBi): The End of Cometing and Polling?

Building "real-time" apps on the web today is a nightmare. We use "Long Polling," where the browser keeps a request open until the server has something to say. We use "Comet," we use hidden iFrames... it’s all a bunch of hacks to get around the fact that HTTP was designed for requesting documents, not for two-way communication. But the "HyBi" working group (part of the HTML5 effort) has a better way: WebSockets.

Full-Duplex over a Single Socket

WebSockets start as a standard HTTP request, but they use an "Upgrade" header to switch to a binary, bidirectional protocol. Once the connection is established, the client and server can send messages to each other at any time. No more headers, no more cookies on every request, just raw data.

// The future of real-time web looks like this
var socket = new WebSocket("ws://example.com/chat");

socket.onmessage = function(event) {
    console.log("Server says: " + event.data);
};

socket.send("Hello Server!");

The overhead is tiny-just a few bytes for the framing. This makes it perfect for things like stock tickers, chat apps, and multiplayer games that would have been impossible or incredibly laggy with standard Ajax.

The Browser Support Challenge

Right now, only the latest "nightly" builds of Chrome and Safari support it. IE and Firefox are still lagging behind. Plus, there are concerns about how transparent proxies and firewalls will handle this new protocol. Some might see it as "invalid" HTTP and kill the connection.

Looking Ahead

WebSockets are the final piece of the "Web as an Application Platform" puzzle. Combined with Canvas and WebGL, we finally have the tools to build apps that are just as responsive as desktop software. We’re moving away from the "Request/Response" cycle and toward a "Stream" model. It’s going to be a few years before we can use it everywhere, but the foundation is being laid today.


Aunimeda develops websites and web applications for businesses - corporate sites, e-commerce, portals, and custom platforms.

Contact us to discuss your web project. See also: Web Development, E-commerce Development

Read Also

SolidJS: Fine-Grained Reactivity and the Death of the Virtual DOM (2021)aunimeda
Web Development

SolidJS: Fine-Grained Reactivity and the Death of the Virtual DOM (2021)

React is great, but why are we re-running our whole component tree? SolidJS proves that fine-grained reactivity is the faster path.

Svelte 3: The Framework that Disappears (2019)aunimeda
Web Development

Svelte 3: The Framework that Disappears (2019)

Svelte 3 is here, and it's doing away with the Virtual DOM entirely. Reactivity is now a language feature, not a library feature.

The TypeScript Tipping Point: Why We Stopped Shipping Raw JavaScript in 2018aunimeda
Web Development

The TypeScript Tipping Point: Why We Stopped Shipping Raw JavaScript in 2018

The days of 'undefined is not a function' are numbered. In 2018, we have officially moved all new agency projects to TypeScript. Here is why static typing is the best investment for long-term project health.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

Web Development

Get Consultation All articles