When I talk about streaming HTML , I am not talking about incrementally requesting HTML to hydrate a page, or whatever the fancy thing is web frameworks do nowadays—no, I am talking about streaming an actual HTML response, creating live updates much like a WebSocket (or actually just an SSE) does, without the need for any JavaScript.
Turns out, it's really easy to do! Basically every single web browser (even ancient ones) will request HTML with Connection: keep-alive, which means you get to be as slow as you want responding!
Realistically, this can be used to make sure the most important parts of the page are loaded first,1 while the rest is loaded later. While mostly forgotten, it's already been explored a bunch. Here, we'll be looking into a more interesting use-case: real-time applications!
Here's a simple webpage to get started with. We'll be embedding the magic chat endpoint into an iframe, and have a little form to send messages: