Skip to content

Instantly share code, notes, and snippets.

@mateuszkocz
Created August 6, 2013 16:34
Show Gist options
  • Save mateuszkocz/6166163 to your computer and use it in GitHub Desktop.
Save mateuszkocz/6166163 to your computer and use it in GitHub Desktop.
insertAdjacentHTML(). Performant way of inserting HTML into a DOM. Source: http://ejohn.org/blog/dom-insertadjacenthtml/
var ul = document.getElementById("list");
ul.insertAdjacentHTML("beforeEnd", "<li>A new li on the list.</li>");
ul.insertAdjacentHTML("beforeEnd", "<li>Another li!</li>");
.insertAdjacentHTML("beforeBegin", ...)
.insertAdjacentHTML("afterBegin", ...)
.insertAdjacentHTML("beforeEnd", ...)
.insertAdjacentHTML("afterEnd", ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment