v148 · HTML · JavaScript
Insertion Method Compare
Chrome 148 adds setHTML(), appendHTML(), and streamHTMLUnsafe() as modern alternatives to innerHTML. Try each method live and see how they differ in sanitization, streaming capability, and DOM semantics. A feature matrix summarises what each method can and cannot do.
Directly sets parsed HTML. No sanitization. Parses synchronously — no streaming possible.
Replaces content with sanitized HTML. Strips scripts and dangerous attributes. Uses the HTML Sanitizer API internally.
Appends sanitized HTML to existing content. Multiple calls accumulate without clearing.
Pipes a ReadableStream of HTML chunks into the element. Content appears progressively as chunks arrive. Unsanitized — use with trusted sources only.
| Feature | innerHTML | setHTML | appendHTML | streamHTMLUnsafe |
|---|---|---|---|---|
| Available pre-148 | ✓ | ✗ | ✗ | ✗ |
| Sanitizes HTML | ✗ no | ✓ yes | ✓ yes | ✗ unsafe |
| Streaming support | ✗ | ✗ | ✗ | ✓ ReadableStream |
| Replaces content | ✓ | ✓ | ✗ (appends) | ✓ |
| Appends to content | manual | ✗ | ✓ | ✗ |
| Strips <script> | ✗ | ✓ | ✓ | ✗ |
| Strips event attrs | ✗ | ✓ | ✓ | ✗ |
| Progressive render | ✗ | ✗ | per-call | ✓ true streaming |
| Sanitizer config | n/a | ✓ optional | ✓ optional | n/a |
see also
- Streaming Feed — streamHTMLUnsafe with live chunks
- HTML Insertion REPL — live method picker
- Template Slots Demo — out-of-order placeholders
- Streaming Race Visualizer — chunk ordering animation
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗