Skip to content

Instantly share code, notes, and snippets.

@olivoil
Forked from stucox/mutationobserver.js
Created May 13, 2013 14:18
Show Gist options
  • Save olivoil/5568630 to your computer and use it in GitHub Desktop.
Save olivoil/5568630 to your computer and use it in GitHub Desktop.
// http://www.w3.org/TR/dom/
// http://updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers
// https://developer.mozilla.org/en-US/docs/DOM/MutationObserver
var MutationObserver = (function () {
var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']
for(var i=0; i < prefixes.length; i++) {
if(prefixes[i] + 'MutationObserver' in window) {
return window[prefixes[i] + 'MutationObserver'];
}
}
return false;
}());
if(MutationObserver) {
// Use MutationObserver
}
else {
// Fallback
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment