Streaming HTML out of order without JavaScript
July 1, 2024
The advantages of streaming HTML over waiting for the entire response to be generated before sending it to the browser are clear – you can render something immediately to indicate to the user that something is happening, and you can start downloading assets like CSS and JavaScript earlier, while you wait for the more time consuming parts of the response to be generated.
What’s been lacking up to this point is a way to stream HTML out of order – that is to stream the HTML in chunks as it’s generated without worrying about the order in which the chunks are sent to the browser – and still have the browser render the chunks of HTML in the correct order as in the demo above.
Modern full stack frameworks enable this functionality by using a variety of clever techniques, all of which require buy-in to the particular framework and a hefty chunk of JavaScript. That might be fine for your use case, but what if we could achieve the same thing without any JavaScript or framework? Well now you can.
Source: lamplightdev – Streaming HTML out of order without JavaScript
What if I told you, you could stream HTML from the server, out of order, without using any JavaScript in the client?
With web components you can.