Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Last active December 4, 2021 21:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomhodgins/d5ce8edfdb6cb87b1f5bcda5518a498a to your computer and use it in GitHub Desktop.
Save tomhodgins/d5ce8edfdb6cb87b1f5bcda5518a498a to your computer and use it in GitHub Desktop.

Vanilla DOM Toolkit

Creating Elements

Working with Element Contents

Working with Attributes

Working with Style Properties

Adding Nodes to DOM

Removing Nodes from DOM

Finding Elements

Traversing & Filtering DOM

Observing Changes (Events and Observers)

Parsers

Stringifiers


Basic HTML tagged template function

function html(strings, ...expressions) {
  return document.createRange().createContextualFragment(
    strings.reduce((output, string, index) =>
      output + String(expressions[index - 1]) + string
    )
  )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment