v148 · html · developer trial (behind a flag)
Out of order streaming
Lets a server update any named region of a streamed HTML document without JavaScript — using processing instruction markers (<?marker name="id">, or a <?start name="id"> … <?end> range) and <template for="id"> elements whose parsed content is inserted at the marker, replacing the range, as it arrives in the stream.
runtime_enabled_features.json5 (branch 7778) marks both DocumentPatching (the <template for> patching) and HTMLProcessingInstruction (parsing the <?marker> / <?start> / <?end> markers) as experimental. To try it in Chrome 148, enable chrome://flags/#enable-experimental-web-platform-features, or launch Chrome with --enable-blink-features=DocumentPatching,HTMLProcessingInstruction. Without the flag the markers do nothing and <template for> is an ordinary inert template, so keep a working fallback for the placeholder content.
at a glance
| Available in | Chrome 148 behind a flag (milestone 148 listing, “In developer trial”); enabled by default in Chrome 150 (milestone 150 listing) |
|---|---|
| Status | Developer trial (behind a flag) in 148; shipped in 150 |
| Flag | chrome://flags/#enable-experimental-web-platform-features, or --enable-blink-features=DocumentPatching,HTMLProcessingInstruction (M148 runtime flags) |
| Standards position | Safari: Support (WebKit/standards-positions#628) · Firefox: Positive (mozilla/standards-positions#1369) |
| Spec | HTML Standard — template for attribute (now in the Living Standard; introduced by whatwg/html PR #11818); HTML Standard — template element |
| Explainer | WICG declarative-partial-updates (patching explainer) |
| Blink component | Blink>HTML |
| ChromeStatus | 5111042975465472 — Out of order streaming (API record) |
why it exists
Classic HTTP streaming delivers content top-to-bottom. If a slow database query powers a section at the top of the page, everything below waits. Today, fixing this requires either JavaScript (e.g. fetch + innerHTML) or multiple round-trips. Out of order streaming is a declarative, zero-JS solution: the server streams a placeholder, continues with fast content below, then later streams a <template for="id"> that the browser uses to replace the placeholder — no script involved.
syntax
Formal syntax
The template element gains a for content attribute, reflected by a new IDL attribute (verbatim from the HTML Standard §4.12.3; the same member is declared under RuntimeEnabled=DocumentPatching in Chromium 148’s html_template_element.idl):
[Exposed=Window]
interface HTMLTemplateElement : HTMLElement {
// … existing members …
[CEReactions, Reflect="for"] attribute DOMString htmlFor;
};
The markers are HTML processing instructions (HTML §13.1.7: <?, a target, optional whitespace and data, an optional ?, then >). Out of order streaming recognises three targets, matched through the name pseudo-attribute in the data:
<?marker name="name"> <!-- a single insertion point -->
<?start name="name"> <!-- start of a replaceable range -->
…placeholder content…
<?end> <!-- end of the range (optional) -->
<template for="name">…replacement content…</template>
<?marker name="id"> | Processing instruction marking a single point. The matching template’s content is inserted at that point; nothing is removed. |
|---|---|
<?start name="id"> | Processing instruction that opens a named range. When the matching template is parsed, every sibling node between it and its matching <?end> is removed and the template’s content is inserted in their place. With no matching <?end>, the range runs to the end of the start marker’s parent. |
<?end> | Processing instruction that closes a range. It carries no name: a later sibling <?start> increments a nesting level, so each <?end> closes the innermost open range among the start marker’s siblings. |
<template for="id"> / htmlFor | The for value must equal the name of a <?marker> or <?start> processing instruction in the same tree. The first matching marker in tree order wins. htmlFor reflects the attribute (a plain DOMString; setting it never throws). |
Correction (2026-11-15): earlier revisions of this page showed <?start id?> / <?end id?> markers. That form appears in neither the standard nor the patching explainer, and Chromium 148’s patch.cc matches the marker / start / end targets on the name pseudo-attribute, exactly as above.
Processing model
- Start tag. When the HTML parser inserts a
<template>that has aforattribute (and noshadowrootmode, which takes precedence), its scope is the node the template is being inserted into. If that is thebodyelement still on the parser’s stack, the scope widens to its parent so a template inbodycan patchhead. - Find markers. The parser walks the scope’s descendants in tree order for the first processing instruction whose
nameequals theforvalue and whose target ismarkerorstart. An emptyforvalue, or no match, means no patching: the template is inserted as an ordinary template and its content stays inert. - Prepare. On a match, the template’s insertion target becomes the marker’s parent. For a range, the nodes between
<?start>and its<?end>are removed immediately. - Stream. The template element itself is still inserted where it appeared, but each child the parser then creates inside it is redirected to the insertion target, before the end marker (or appended to the target if the end marker has moved or been removed). Content therefore appears incrementally as it arrives.
- End tag. At
</template>the start and end markers are removed, so each marker can be patched only once. Nested patching (afortemplate inside another) is not supported.
This is a parser behaviour: it runs during document parsing and in the spec’s fragment-parsing case; setting htmlFor or inserting a template through DOM methods does not patch anything. There are no exceptions to handle: a template that matches nothing silently falls back to normal template behaviour.
for attribute, prepare content patching and find markers; HTML Standard — template start/end tag parsing; HTML §13.1.7 processing instructions; whatwg/html PR #11818; WICG patching explainer. Read 2026-11-15.
how it works (examples)
Declarative streaming replaces placeholder ranges in-place as subsequent HTML arrives across the connection:
1. Mark a region with PI range markers
The server emits processing instructions to delimit the region that should be replaced later. These require the Parse processing instructions in HTML feature (also behind a flag in 148).
<!-- Server streams this first -->
<main>
<?start name="slow-section">
<p>Loading…</p>
<?end>
<p>Fast content rendered immediately.</p>
</main>
2. Stream a replacement template later
When the slow data is ready, the server writes a <template for="slow-section"> later in the same stream, inside an ancestor of the markers (here, still inside <main> or after it in <body>). The browser removes the placeholder between the markers and inserts the template’s content in their place — no JS required.
<!-- Server streams this after the slow query completes -->
<template for="slow-section">
<article>
<h2>Top result: Gadget X</h2>
<p>Price: $49 — In stock</p>
</article>
</template>
Result
The user sees “Loading…” for the slow section, while fast content below renders immediately. When the template arrives, the placeholder is replaced in place; the markers are removed at </template>.
3. Insert at a single point with <?marker>
Adapted from the HTML Standard’s own example: a <?marker> inside a select is filled later by a template.
<select id="countries"><?marker name="country-options"></select>
<!-- … rest of the page … -->
<template for="country-options"><option>Antigua</option><!-- … --></template>
Source: HTML Standard §4.12.3 examples (out-of-order countries, async recommendation engine).
4. Feature-detect and read htmlFor
const supportsPatching = 'htmlFor' in HTMLTemplateElement.prototype;
const t = document.createElement('template');
t.htmlFor = 'slow-section'; // reflects to the for="" content attribute
console.log(t.getAttribute('for')); // "slow-section"
// Note: creating or inserting a template from script does NOT patch;
// only the HTML parser runs the patching steps.
Live demo
All five interactive demos for this feature are on the chrome-platform-showcase feature page. The embed below is the template-slots concept. In Chrome 148 it needs the flag above.
browser compatibility
Per-version data from mdn/browser-compat-data (fetched raw 2026-11-15): html.elements.template.for, api.HTMLTemplateElement.htmlFor and api.ProcessingInstruction.doc_html (the HTML-parsed markers). All three carry identical support and are flagged experimental.
| Browser | Version added | Notes |
|---|---|---|
| Chrome | 150 | 148: behind a flag (developer trial). BCD does not record the flag; it comes from the M148 runtime flags (DocumentPatching, HTMLProcessingInstruction: experimental). Chrome Android 150 per webstatus.dev. |
| Edge | 150 | BCD "edge": "mirror"; webstatus.dev records Edge 150 (2026-07-02). |
| Firefox | Not supported | BCD version_added: false. Standards position: Positive (mozilla/standards-positions#1369). |
| Safari | Not supported | BCD version_added: false. Standards position: Support (WebKit/standards-positions#628). |
Feature detection. 'htmlFor' in HTMLTemplateElement.prototype is true only where the IDL attribute is exposed (Chrome 150+, or 148 with the flag). Because patching happens in the parser, design the placeholder so the page still works when the template is ignored.
specifications
| Specification | Status |
|---|---|
HTML Standard §4.12.3 — the template element, for attribute | Living Standard (added by whatwg/html PR #11818) |
| HTML Standard §13.1.7 — processing instructions | Living Standard |
see also
- whatwg/html PR #11818 — spec draft
- WICG declarative-partial-updates repository
- Parse processing instructions in HTML — prerequisite feature
- Renewed HTML insertion & streaming methods — JS-based companion
- chromestatus: Out of order streaming
- Chromium tracking issue 431374376
- chrome-platform-showcase: demos