A Cloudflare Workers Demo for HTML Streaming Performance
This demo shows how streaming the <head> before the <body> improves page load performance. The browser can download CSS, fonts, and JS in parallel while the server fetches data.
Browser receives <head> instantly.
Downloads CSS/JS in parallel with server work.
Total: ~2000ms
Browser waits for entire response.
Downloads CSS/JS after server finishes.
Total: ~2800ms
TransformStream to send the <head>
immediately via ctx.waitUntil(), then continues fetching data. The browser parses
the <head> and starts downloading CSS/JS assets while the server is still working.