← Chrome 148 reference

v148 · html · developer trial (behind a flag)

Out of order streaming

Limited availability

  • Chrome · 150 (148 behind a flag)
  • Edge · 150
  • Firefox · not shipped
  • Safari · not shipped

Not Baseline. webstatus.dev reports the template-for web feature as limited availability (API record, queried 2026-11-15): Chrome and Chrome Android 150 (2026-06-30), Edge 150 (2026-07-02), no Firefox or Safari implementation. See the full table.

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.

Developer trial in Chrome 148 — behind a flag Chrome 148 lists this feature under In developer trial (Behind a flag) in the milestone-148 listing; it is enabled by default only from Chrome 150 (milestone-150 listing). Chromium 148’s 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 inChrome 148 behind a flag (milestone 148 listing, “In developer trial”); enabled by default in Chrome 150 (milestone 150 listing)
StatusDeveloper trial (behind a flag) in 148; shipped in 150
Flagchrome://flags/#enable-experimental-web-platform-features, or --enable-blink-features=DocumentPatching,HTMLProcessingInstruction (M148 runtime flags)
Standards positionSafari: Support (WebKit/standards-positions#628)  ·  Firefox: Positive (mozilla/standards-positions#1369)
SpecHTML Standard — template for attribute (now in the Living Standard; introduced by whatwg/html PR #11818); HTML Standard — template element
ExplainerWICG declarative-partial-updates (patching explainer)
Blink componentBlink>HTML
ChromeStatus5111042975465472 — 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.

Source: chromestatus summary and whatwg/html PR #11818.

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"> / htmlForThe 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

  1. Start tag. When the HTML parser inserts a <template> that has a for attribute (and no shadowrootmode, which takes precedence), its scope is the node the template is being inserted into. If that is the body element still on the parser’s stack, the scope widens to its parent so a template in body can patch head.
  2. Find markers. The parser walks the scope’s descendants in tree order for the first processing instruction whose name equals the for value and whose target is marker or start. An empty for value, or no match, means no patching: the template is inserted as an ordinary template and its content stays inert.
  3. 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.
  4. 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.
  5. End tag. At </template> the start and end markers are removed, so each marker can be patched only once. Nested patching (a for template 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.

Source: HTML Standard — 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.

Live example from the Chrome Platform Showcase (route checked 200, 2026-11-15). Other concepts: streaming feed, streaming race visualizer, HTML insertion REPL, insertion method compare.Source: chrome-platform-showcase

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 support for <template for>, htmlFor and HTML-parsed marker processing instructions
BrowserVersion addedNotes
Chrome150148: 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.
Edge150BCD "edge": "mirror"; webstatus.dev records Edge 150 (2026-07-02).
FirefoxNot supportedBCD version_added: false. Standards position: Positive (mozilla/standards-positions#1369).
SafariNot supportedBCD 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.

Source: BCD html/elements/template.json; BCD api/HTMLTemplateElement.json; BCD api/ProcessingInstruction.json; webstatus.dev template-for; chromestatus browser views.

specifications

Source: HTML Living Standard, read 2026-11-15.

see also