This episode traces the evolution of the real-time web: from static web pages that could only do request-response, short polling, long polling, to Server-Sent Events. You will understand the problems that ultimately drove the birth of WebSocket as the solution.

Before understanding WebSocket, you must understand the problem it solves. WebSocket did not appear out of thin air — it is the answer to decades of developer effort to make the web "communicate in real-time".
Episode 1 takes you through that evolution step by step: static web pages that could only be reloaded, wasteful short polling, long polling that is smarter but still heavy, and one-way Server-Sent Events. By the end of the episode you will see why none of these approaches were enough — and that is the gap WebSocket fills.
In the early days of the web, every interaction followed a single pattern: the browser sends a request, the server returns a response, and the page finishes loading. If there is new data on the server, the browser will not know until you press the refresh button.
This model works well for documents and pages that rarely change. Problems arise when an application needs constantly updated data — for example, stock prices, match scores, or chat notifications. HTTP is a stateless protocol: every request stands alone, and the server does not keep context between requests.
As a result, the simplest idea that occurred to early developers was: ask the page to reload periodically.
Short polling is the most naive approach: the client asks the server for data every few seconds, for example every 5 seconds, regardless of whether there is new data or not.
setInterval(async () => {
const res = await fetch("/api/status");
const data = await res.json();
render(data);
}, 5000);The code above asks the /api/status endpoint every 5 seconds. setInterval(async () => {...}, 5000) is the core of short polling — a timer that triggers requests repeatedly with no stopping condition.
Short polling works, but at a high cost:
Imagine 10,000 clients polling every 5 seconds: the server receives 120,000 requests per minute just to say "nothing new".
Long polling fixes the main problem of short polling. Instead of closing the connection after a response, the server holds the response open until there is data truly ready to be sent.
The flow: the client sends a request, the server holds it, and only sends a response when new data becomes available. After the data is received, the client immediately creates a new request to "reconnect".
async function longPoll() {
const res = await fetch("/api/events");
const event = await res.json();
render(event);
longPoll();
}
longPoll();The longPoll() pattern that calls itself after receiving an event mimics Comet behavior. The server holds the fetch("/api/events") request open for as long as possible.
Long polling is far more responsive than short polling: data is sent almost instantly when it becomes available. But other problems appear:
Long polling was a big leap, but still far from an ideal solution.
Server-Sent Events (SSE) arrived with HTML5 and leverages an existing protocol: an ordinary HTTP connection left open. The key difference — the server pushes data to the client over a single long-lived connection, without the client asking repeatedly.
const sse = new EventSource("/api/stream");
sse.onmessage = (event) => {
render(JSON.parse(event.data));
};With new EventSource("/api/stream"), the browser establishes a persistent connection. sse.onmessage is invoked every time the server sends data. SSE also has automatic reconnection and event IDs for position recovery — two features polling does not have.
SSE solves the server-to-client direction, but not fully:
SSE remains a good choice for notifications and live feeds, but for two-way chat it is not enough.
From the journey above, a consistent set of needs emerges:
WebSocket satisfies all of those needs with a single persistent TCP connection. It began as just a browser proposal, then was standardized as RFC 6455 in 2011. Today WebSocket is the backbone of real-time applications: chat, multiplayer games, document collaboration, live dashboards, and trading platforms.
refresh manual → short polling → long polling → SSE → WebSocketThe flow refresh manual → short polling → long polling → SSE → WebSocket is a mental summary that will stay with you throughout this series.
Episode 1 shows that WebSocket is the result of an evolution, not a sudden invention. Each previous approach solved one problem but created another: short polling is wasteful, long polling is complex, and SSE is one-way.
Key takeaways:
In the next episode we will dissect the WebSocket protocol itself — the RFC 6455 standard, the ws:// and wss:// schemes, and a comparison of WebSocket with SSE and HTTP/2 Server Push. You will begin to see the inner workings of the protocol you are learning.