Skip to content

Instantly share code, notes, and snippets.

@stucox
Created March 24, 2013 09:36
Show Gist options
  • Save stucox/5231211 to your computer and use it in GitHub Desktop.
Save stucox/5231211 to your computer and use it in GitHub Desktop.
Mutation Observer feature detection
// 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