LmCast :: Stay tuned in

API proposed by Chrome: Declarative partial updates

Recorded: May 24, 2026, 3:58 a.m.

Original Summarized

Declarative partial updates  |  Blog  |  Chrome for Developers


Skip to main content

Docs

Build with Chrome
Learn how Chrome works, participate in origin trials, and build with Chrome everywhere.

Web Platform

Capabilities

ChromeDriver

Extensions

Chrome Web Store

Chromium

Web on Android

Origin trials

Release notes

Productivity
Create the best experience for your users with the web's best tools.

DevTools

Lighthouse

Chrome UX Report

Accessibility

Modern Web Guidance

Get things done quicker and neater, with our ready-made libraries.

Workbox

Puppeteer

Experience
Design a beautiful and performant web with Chrome.

AI

Performance

CSS and UI

Identity

Payments

Privacy and security

Resources
More from Chrome and Google.

All documentation

Baseline

web.dev

PageSpeed Insights audit

The Privacy Sandbox

Isolated Web Apps (IWA)

Case studies

Blog

New in Chrome

/

English

Deutsch

Español – América Latina

Français

Indonesia

Italiano

Nederlands

Polski

Português – Brasil

Tiếng Việt

Türkçe

Русский

עברית

العربيّة

فارسی

हिंदी

বাংলা

ภาษาไทย

中文 – 简体

中文 – 繁體

日本語

한국어

Sign in


Blog

Docs

More

Case studies

Blog

New in Chrome

Build with Chrome

Web Platform

Capabilities

ChromeDriver

Extensions

Chrome Web Store

Chromium

Web on Android

Origin trials

Release notes

Productivity

DevTools

Lighthouse

Chrome UX Report

Accessibility

Modern Web Guidance

Workbox

Puppeteer

Experience

AI

Performance

CSS and UI

Identity

Payments

Privacy and security

Resources

All documentation

Baseline

web.dev

PageSpeed Insights audit

The Privacy Sandbox

Isolated Web Apps (IWA)


Chrome for Developers


Blog

Declarative partial updates


Stay organized with collections


Save and categorize content based on your preferences.


Barry Pollard

X

GitHub

Mastodon

Bluesky

Homepage


Noam Rosenthal

X

GitHub

Mastodon

Published: May 19, 2026

The web has long since moved on from the static, document-driven medium that it started as. Modern, rich web apps are used by everyone for many reasons, from communicating, purchasing, consuming rich content, to managing our complex lives.
HTML, despite all its advances, is still delivered in-order in a top-to-bottom fashion with little regard for when content is ready or when the user consumes it. CSS lets you change the ordering of content, but often with significant accessibility side effects. JavaScript lets you manipulate the DOM through various APIs to break free of this somewhat, but those often require verbose syntax or construction of DOM trees to plug into HTML.
Performance is incredibly important for the web, given the client-server nature of the medium but suboptimal choices are often made to circumvent this in-order nature of HTML, which slows down performance. This includes waiting until the whole page is ready or using a heavy framework to deliver components in an asynchronous manner. The popularity of JavaScript frameworks shows that web developers prefer a component-based model rather than the rigid document mental model of the web's origins.
The Chrome team has been considering this problem and has been developing new additions to the web platform under the name of Declarative Partial Updates.
Two new sets of APIs make it easier to deliver HTML in a less linear fashion, whether out-of-order in the HTML document itself or through easier ways to dynamically insert HTML into existing documents using new JavaScript APIs. These are ready for developer testing from Chrome 148 using the chrome://flags/#enable-experimental-web-platform-features flag. Polyfills are also available to let you use these new APIs right away, even in browsers that don't yet support them.
These additions to the web platform are being standardized with positive feedback from other browser vendors and standardization avenues. The relevant standards are in the process of being updated to include these new APIs.
Out-of-order streaming
The first set of changes are new out-of-order streaming APIs using the <template> HTML element and processing instruction placeholders. For example:
<div>
<?marker name="placeholder">
</div>

...

<template for="placeholder">
Here is some <em>HTML content</em>!
</template>

Processing instructions have existed in XML for a long time, but have been treated as comments in HTML and ignored. This new API changes that and brings processing instructions to HTML. When the browser sees the <?marker name="placeholder"> processing instructions, it doesn't do anything straight away—much like before—but they can be referenced later.
The <template> element looks up the corresponding processing instructions with a name attribute and replaces the content. In this case, after being parsed, the DOM ends up as:
<div>
Here is some <em>HTML content</em>!
</div>

As well as the <?marker> attribute for replacements, there are also <?start> and <?end> range markers which allow for temporary placeholder content to be shown before the template is processed:
<div>
<?start name="another-placeholder">
Loading…
<?end>
</div>

...

<template for="another-placeholder">
Here is some <em>HTML content</em>!
</template>

In this case, Loading… shows until the <template> is seen and then is replaced with the new content.
It is also possible to include processing instructions in templates to allow multiple updates:
<ul id="results">
<?start name="results">
Loading…
<?end>
</ul>

...

<template for="results">
<li>Result One</li>
<?marker name="results">
</template>
...

<template for="results">
<li>Result Two</li>
<?marker name="results">
</template>
...

This results in the following HTML after being parsed:
<ul id="results">
<li>Result One</li>
<li>Result Two</li>
<?marker name="results">
</ul>

With the final processing instruction at the end in case any more <template for="results"> are added to the document later.
Demo
In this video, a basic photo album application is implemented with streaming HTML:

Photo album demo implemented with out-of-order streaming (source)

Both the status and photos are streamed into the HTML after the initial layout.
Use cases
There are many use cases for this out-of-order patching HTML when coupled with streaming HTML:

Island architecture. A common pattern popularized by frameworks like Astro the island architecture where components are hydrated independently on top of static HTML. The <template for> API lets static content be handled in a similar fashion directly in HTML. JavaScript frameworks can also use this for more interactive islands or to handle components.
Delivery content when it is ready. Thanks to this island architecture, content can be streamed when it is ready rather than held back for content that requires extra processing, for example, a database lookup. While many platforms allow streaming HTML, the in-order nature of HTML means that content is often held back, or by resorting to complex JavaScript DOM manipulations. Now you can deliver the static content while waiting, and then plug in the more expensive content at the end of the HTML stream.
HTML can be delivered in the optimal order for page load performance. Taking this one step further, you can change the order even when it is ready. For example, mega menus are a common navigation feature that contain a lot of HTML that the user won't see until the page becomes interactive. This large chunk of HTML can be delivered later in the HTML document to prioritize more important HTML needed for the initial page load. Order is no longer a barrier with HTML.

These are just some use cases, and it is exciting to see what developers use this new API for.
Restrictions and subtleties
The API includes a few restrictions and subtleties to be aware of:

<template for> can only update processing instructions within the same parent element for security reasons. Adding <template for> directly to the <body> element gives it access to the whole document (including the <head>).
The <?end> processing instruction is optional and if missing, the content between the <?start> element and the end of the containing element will be replaced.
Moving processing instructions after a <template for> has started streaming can also have unexpected consequences with the new content continuing to stream into the old location.
Note that when inserting <template for> dynamically with method like setHTML or innerHTML, the "parent" of the template when it is parsed is an intermediate document fragment. That means that inserting HTML using these methods cannot modify existing DOM, and the patching happens "in place" inside the fragment. However, when streaming using methods like streamHTMLUnsafe (that we're about to cover!), there is no intermediate fragment so the templates can replace existing content.

Future potential additions
Some potential future additions that are under consideration include:

Client side includes. For example, <template for="footer" patchsrc="/partials/footer.html">.
Batching. Client-side, fragment includes could also be extended to handle batching to ensure multiple updates happen at the same time.
Preventing overwriting content that will not change. This could be achieved with a content revision number or versioning. This would let state be maintained between route changes or other updates rather than resetting the content.
Sanitizing while patching. For example, <template for=icon safe><svg id="from-untrusted-source">...</svg></template>

Polyfill
The Chrome team has released a template-for-polyfill which is available on npm to let sites use this new functionality right away even before this lands in other browsers.
There are some limitations as it cannot directly update browser's HTML parsers, but the most common use cases are covered. Sites should still test in other browsers.
Renewed HTML insertion and streaming methods
Not all content can be delivered in HTML. A second part of the work Chrome is doing in this area involves making it easier to update content through JavaScript.
There already are multiple ways to dynamically inject HTML into an existing document using JavaScript:

setHTML
setHTMLUnsafe
innerHTML and outerHTML setters
createContextualFragment
insertAdjacentHTML

However, they all work in slightly different ways with subtleties and differences that developers may not always consider:

Does the new content overwrite or append?
Do they sanitize potentially dangerous HTML by escaping <script> tags, for example?
If not, should <script>'s run?
How do they work with TrustedTypes?

Few developers could honestly look at those APIs and confidently answer those questions for each of them.
A big limitation is that they can only be used for a complete set of HTML known in advance, when there have been calls to allow HTML to be streamed. Practically, this means you need to download the entire content before inserting it, when one of the strong points of HTML is the ability to stream in content right away. This can be worked around in a limited fashion by splitting up payloads or using hacky, deprecated methods like document.write, but they introduce their own problems.
A new set of Static and Streaming APIs
Chrome has proposed a suite of new APIs and extensions to the existing setHTML and setHTMLUnsafe that cleans this up, as well as introducing streaming functionality:
There are methods to set or replace along with methods to insert content before or after existing HTML. Each method has stream equivalents:

Action
Static
Streaming

Set the HTML contents of the element
setHTML(html, options);
streamHTML(options);

Replace the entire element with this HTML
replaceWithHTML(html, options);
streamReplaceWithHTML(options);

Add the HTML before the element
beforeHTML(html, options);
streamBeforeHTML(options);

Add the HTML as the first child of the element
prependHTML(html, options);
streamPrependHTML(options);

Add the HTML as the last child of the element
appendHTML(html, options);
streamAppendHTML(options);

Add the HTML after the element
afterHTML(html, options);
streamAfterHTML(options);

The new insertion and streaming methods

There are also Unsafe versions we'll cover shortly. While there might appear to be a lot of them (especially when you add in the Unsafe equivalents), the consistent naming convention makes it more obvious what each does compared to the unrelated methods mentioned previously.
The static versions take new HTML as a DOM String argument, along with optional options:
const newHTML = "<p>This is a new paragraph</p>";
const contentElement = document.querySelector('#content-to-update');

contentElement.setHTML(newHTML);

The streaming versions work with the Streams API such as with a getWriter():
const contentElement = document.querySelector('#content-to-update');
const writer = contentElement.streamHTMLUnsafe().getWriter();

// Example stream of updating content
while (true) {
await writer.write(`<p>${++i}</p>`);
await new Promise((resolve) => setTimeout(resolve, 1000));
}

writer.close();

Or, alternatively from a fetch response, with pipe chains:
const contentElement = document.querySelector('#content-to-update');

const response = await fetch('/api/content.html');

response.body
.pipeThrough(new TextDecoderStream())
.pipeTo(contentElement.streamHTMLUnsafe());

We're also planning to add a convenience method where you can stream directly without needing the intermediate TextDecoderStream() step.
The options argument lets you specify a custom sanitizer which defaults to default meaning the default sanitizer config. It is used like so:
const newHTML = "<p>This is a new paragraph</p>";
const contentElement = document.querySelector('#content-to-update');

// Only allows basic formatting
const basicFormattingSanitzer = new Sanitizer({ elements: ["em", "i", "b", "strong"] });

contentElement.setHTML(newHTML, {sanitizer: basicFormattingSanitzer});

"Unsafe" methods
There are also "unsafe" versions of each of the APIs:

Action
Static
Streaming

Set the HTML contents of the element
setHTMLUnsafe(html,options);
streamHTMLUnsafe(options);

Replace the entire element with this HTML
replaceWithHTMLUnsafe(html, options);
streamReplaceWithHTMLUnsafe(options);

Add the HTML before the element
beforeHTMLUnsafe(html, options);
streamBeforeHTMLUnsafe(options);

Add the HTML as the first child of the element
prependHTMLUnsafe(html, options);
streamPrependHTMLUnsafe(options);

Add the HTML as the last child of the element
appendHTMLUnsafe(html, options);
streamAppendHTMLUnsafe(options);

Add the HTML after the element
afterHTMLUnsafe(html, options);
streamAfterHTMLUnsafe(options);

The "unsafe" insertion and streaming methods

These "unsafe" methods switch off the sanitizer by default (you can specify a custom sanitizer if you wish) and also allow scripts to be run with an optional runScripts option (which defaults to false).
Like setHTML, setHTMLUnsafe is an existing method, but the runScripts options parameter has been added to it to allow it to be used with script execution:
const newHTML = `<p>This is a new paragraph</p>
<script src=script.js></script>`;
const contentElement = document.querySelector('#content-to-update');

contentElement.setHTMLUnsafe(newHTML, {runScripts: true});

The "unsafe" wording in the method is to remind developers of the potential risk and how they may want to sanitize or restrict scripts, not to say that these methods shouldn't be used.
How "unsafe" this is depends on how trusted the inputs are. The Unsafe static methods all work with both DOM String or TrustedHTML as the html arguments and also allow sanitizers to be used. Though with runScript the whole intent is to allow scripts, hence why by default no sanitizer is used.
Use cases
These new APIs make it easier for developers to add HTML to existing pages, adding new APIs with consistent names and options. The streaming APIs bring the performance benefits of not having to wait until all the new content is available to the platform.
Use cases include:

Dynamic streaming of large content updates in Single Page Apps. As mentioned previously, a big drawback of current SPAs is they couldn't benefit from the streaming nature of initial HTML loads—until now!
Inserting common content like HTML footers. Using the JavaScript APIs lets you pull in partials and insert them into the page, benefiting from caching, rather than repeating them in every page sent. However, given the dependency on JavaScript to run, this should only be used for content that is not going to be visible in the initial load.

Again, those are just a couple of examples and we're eager to see what you all come up with!
Restrictions and subtleties
These new APIs also include a few restrictions and subtleties to be aware of:

Integration of streaming with the Trusted Types API requires using a new createParserOptions method which allows injecting a sanitizer to any HTML setting operation. See the explainer for more details on trusted types integration
Similar to <template for> moving elements that are being streamed into, can create unexpected consequences or stream errors.
streamHTMLUnsafe works more like the main parser in many ways, including processing <template for> instructions as they are added to the main document and deferring defer scripts until the end of the stream.

Polyfill
The Chrome team has released a html-setters-polyfill which is available on npm to let sites use this new functionality right away even before this lands in other browsers.
Note that this polyfill does not stream, and instead buffers and applies when complete. It's more a polyfill for the API shape than for functionality.
Additionally, setting of safe content depends on setHTML and the Sanitizer API which is not supported in Safari.
Use these both together
While these are two separate APIs, real power comes from combining them. By streaming new <template for> elements into the HTML, you can dynamically update different parts of content without having to directly target each with separate JavaScript references to the DOM.
A basic SPA-style page load could be implemented by loading an outline page with processing instructions and then streaming each new page's templates into the bottom of the HTML to slot into those processing instructions.
Undoubtedly there is more potential and use-cases for both these APIs so don't let our (limited!) imaginations hold you back. By making partial updates easier to manage you can reduce some of the boilerplate code, make updates easier, and unlock new potential for the web!

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-19 UTC.

Contribute



File a bug






See open issues

Related content



Chromium updates



Case studies



Archive






Podcasts & shows

Follow



@ChromiumDev on X



YouTube



Chrome for Developers on LinkedIn






RSS

Terms

Privacy

Manage cookies

English

Deutsch

Español – América Latina

Français

Indonesia

Italiano

Nederlands

Polski

Português – Brasil

Tiếng Việt

Türkçe

Русский

עברית

العربيّة

فارسی

हिंदी

বাংলা

ภาษาไทย

中文 – 简体

中文 – 繁體

日本語

한국어

The web has evolved beyond its original static, document-driven medium, with modern rich web applications serving diverse needs ranging from communication to complex content management. Despite advancements in HTML and CSS, the inherent in-order delivery of content presents performance challenges in a client-server environment, often necessitating verbose JavaScript for DOM manipulation or the use of heavy frameworks to implement asynchronous component delivery. Recognizing this limitation, the Chrome team is developing Declarative Partial Updates to facilitate a less linear delivery of HTML, enabling content to be delivered out-of-order or dynamically inserted using new JavaScript APIs, which can be tested via Chrome flags starting in version 148.

This initiative introduces two main sets of APIs aimed at improving web performance by relaxing the rigid document mental model. The first set involves out-of-order streaming, utilizing the new <template> HTML element and processing instruction placeholders. This mechanism allows HTML to be delivered in a non-sequential manner. For instance, processing instructions, which were previously ignored in HTML, are now integrated, allowing content to be referenced later. The <template for> API allows content to be replaced based on these instructions. Furthermore, the API includes <?start> and <?end> range markers to display temporary placeholder content while templates are being processed, demonstrating how non-linear HTML content can be streamed and slotted into the document. These techniques offer potential use cases such as the island architecture, enabling components to hydrate independently of static HTML, content delivery when it is ready, and reordering content, such as in mega menus, to prioritize critical elements for initial page load performance.

The second major focus addresses dynamic insertion and streaming through enhanced methods for updating content using JavaScript. Existing methods like setHTML, innerHTML, and insertAdjacentHTML possess subtleties regarding content replacement, sanitization, and script execution that developers often struggle to manage consistently. To address this complexity, Chrome proposes a new suite of Static and Streaming APIs that standardize insertion and streaming operations. These APIs introduce corresponding methods for setting, replacing, adding content before, after, or as a child of an element, along with streaming equivalents. For operations, there are explicit Static versions and Streaming versions, depending on whether the content is delivered immediately or through a stream.

The API set includes 'Unsafe' versions, such as setHTMLUnsafe and streamHTMLUnsafe, which bypass default sanitization and allow for the execution of scripts via an optional runScripts parameter. This distinction is crucial as it acknowledges the varying levels of trust in the input source, allowing developers to manage the security implications explicitly. The streaming methods interact with the Streams API, enabling performance benefits by avoiding the need to wait for the entire content payload before inserting updates. This allows for dynamic streaming of large content updates in Single Page Applications by delivering content as it becomes available.

Combining these capabilities offers significant potential. By streaming <template for> elements alongside dynamic insertion methods, developers can achieve sophisticated content management where dynamic HTML can be slotted into pre-defined processing instruction locations. This combination allows for the dynamic update of different parts of content without needing complex, direct DOM manipulation, thereby reducing boilerplate code and unlocking new performance potentials for the web platform. While considerations remain regarding the integration with the Trusted Types API and potential streaming errors, the overall aim is to make partial updates easier to manage, leading to more efficient and performant web applications.