Skip to content

Instantly share code, notes, and snippets.

@saitergun
Created March 4, 2022 17:44
Show Gist options
  • Save saitergun/15ec00776ec68fc51183f4066626a643 to your computer and use it in GitHub Desktop.
Save saitergun/15ec00776ec68fc51183f4066626a643 to your computer and use it in GitHub Desktop.
// select the target node
var target = document.querySelector('title')
// create an observer instance
var observer = new MutationObserver(function(mutations) {
// We need only first event and only new value of the title
console.log('title changes', document.title)
})
// configuration of the observer:
var config = { subtree: true, characterData: true, childList: true }
// pass in the target node, as well as the observer options
observer.observe(target, config)
// credit https://stackoverflow.com/a/29540461/5765524
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment