Skip to content

Instantly share code, notes, and snippets.

@bfolkens
Created December 18, 2020 17:02
Show Gist options
  • Save bfolkens/c1e69f7cc67ec6d8b3dafe42f4e93a1e to your computer and use it in GitHub Desktop.
Save bfolkens/c1e69f7cc67ec6d8b3dafe42f4e93a1e to your computer and use it in GitHub Desktop.
Javascript MutationObserver example
// Test for now - eventually use this to continue
const mutationObserver = new MutationObserver(mutations => {
mutations.forEach(mutation => {
console.debug(mutation)
})
})
mutationObserver.observe(elementToWatch, {
attributes: true,
characterData: true,
childList: true,
subtree: true,
attributeOldValue: true,
characterDataOldValue: true
})
... do some stuff
mutationObserver.disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment