JavaScript Gets a New Set of HTML Insertion APIs 0 ▲ Amit Merchant 26 minutes ago · 6 min read1159 words · Tech · hide There are several ways to insert HTML into a web page using JavaScript. You can use innerHTML, insertAdjacentHTML(), createContextualFragment(), or even the relatively newer setHTML() method. They all get the job done, but they don’t necessarily behave in the same way. Some replace existing content, some append it, and some provide built-in HTML sanitization. If you want to stream HTML into an element, things get a little more complicated. Chrome (and Edge) is trying to bring some consistency to this with a new set of HTML insertion and streaming methods. These methods provide a more descriptive way to insert HTML into an existing element, along with the ability to stream content directly into the DOM. Let’s see how these methods work and how they compare to the existing ones. A more consistent way to insert HTML HTML insertion with sanitization built in Streaming HTML directly into the DOM Browser support In Closing A more consistent way to insert HTML If you’ve used… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town