v148 · HTML · JavaScript
Declarative Partial Updates
Two new ways to insert HTML: out-of-order streaming with <template for> placeholders, and a revamped suite of JavaScript insertion methods — setHTML(), appendHTML(), streamHTMLUnsafe() — with Streams API integration.
concepts
-
Streaming Feed
Watch a server response stream into the page in real time using
streamHTMLUnsafe(). Content appears progressively as chunks arrive — no waiting for the full payload before rendering starts. -
HTML Insertion REPL
Live playground for the new insertion methods. Type HTML, pick a method —
setHTML,appendHTML,replaceChildren— and see it applied to the target element immediately. -
Template Slots Demo
Placeholders using
<template for="id">hold positions in the document while content streams in any order — item 3 can arrive before item 1, and the layout stays stable. Compare side-by-side with traditional in-order streaming. -
Streaming Race Visualizer
Animated simulation of chunks arriving in the wrong order. Left panel shows raw chunk arrivals with configurable delays; right panel shows the rendered output. Toggle old vs new behavior to see old in-order blocking vs progressive out-of-order rendering. Includes a
moveBefore()state preservation demo where input values survive re-ordering. -
Insertion Method Comparison
Four tabbed panels comparing
innerHTML(legacy/XSS risk),setHTML()(sanitized replace),appendHTML()(sanitized append), andstreamHTMLUnsafe()(streaming). A feature matrix table shows 9 dimensions across all four methods. Each panel has a live try-it area with XSS test content that shows sanitization in action.
why it shipped
The existing innerHTML setter has two problems: it blocks until the full string is available (no streaming), and it doesn't compose with the Sanitizer API. Meanwhile, server-rendered HTML often arrives in a linear order that's dictated by backend logic, not by what the browser needs first. Declarative Partial Updates addresses both: streamHTMLUnsafe() lets you pipe a ReadableStream of HTML directly into a DOM element — chunks parse and render as they arrive, exactly like the main HTML parser. The out-of-order variant uses HTML processing instructions as named placeholders that <template for="name"> elements fill once they arrive, enabling island architecture without any JavaScript hydration framework. The JS insertion methods (setHTML, appendHTML, parseHTML) give consistent, sanitizer-aware equivalents to the old innerHTML/insertAdjacentHTML pair.
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗