What do the new HTML insertion and streaming APIs actually improve?

November 23, 2026 3 answers
Asked by Tavzelo-7p

Chrome and Edge are adding methods for inserting HTML and streaming it into the DOM. Are these mainly a readability improvement, or do they change how existing approaches work?

Answers

_r48+zeldmavi.6

The insertion methods give you more descriptive ways to work with HTML outside a component tree. For example, appendHTML makes the intent clearer than insertAdjacentHTML with a beforeend position. That could be handy for plain DOM fragments, older widgets, and embeds.

Streaming is a separate capability: it lets content be delivered into the DOM as a stream rather than waiting for one complete HTML string. How useful that is will depend on the project, not every page needs it.

Reply to this answer
_c59~plendari.4

Watch the fallback. If you feature-detect appendHTML and fall back to insertAdjacentHTML, you haven't preserved the same security behavior. The fallback does not sanitize the string.

That can be fine for static markup you control, but user content needs proper sanitization before it reaches an unsafe insertion method. Script tags not executing in that situation doesn't make the HTML safe. An image with an event handler can still execute code.

Tavzelo-7p:

So the fallback needs to be reviewed for security, not just whether it produces the same markup?

3e+canvasmaraca_582:

Exactly. A fallback that looks identical on the page can have very different behavior with untrusted input.

Reply to this answer
5t!cobblecaper_294

Browser support is the practical snag. Check the browsers you need to support before replacing existing code, and feature-detect methods that may be missing. The nicer syntax isn't much help if the fallback changes behavior or adds a security hole.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions