August 2024
Intermediate to advanced
186 pages
4h 3m
English
Server-sent events[81] (SSE) are used to send data from a server to a client, but not in the other direction.
Common uses of SSE include:
The messages sent from SSE endpoints don’t include HTTP headers, so they can be much smaller than HTTP response messages.
Let’s recreate the countdown app we implemented using WebSockets, but this time we’ll use server-sent events.
The following HTML connects to an SSE server and receives server-sent events. Note the use of the EventSource JavaScript class.
First, we load some CSS and declare a couple of JavaScript variables. ...
Read now
Unlock full access