Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Last active April 13, 2016 14:02
Show Gist options
  • Save AllThingsSmitty/fd2b021d46b2c9fb2d32 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/fd2b021d46b2c9fb2d32 to your computer and use it in GitHub Desktop.
Revised cut-the-mustard browser feature detection
// Streamlined CTM method using Page Visibility API (http://caniuse.com/#feat=pagevisibility)
if ('visibilityState' in document) {
// Modern browser, add JS functionality
}
// Previous CTM method based on which DOM features are present
if('querySelector' in document
&& 'localStorage' in window
&& 'addEventListener' in window) {
// Modern browser, add JS functionality
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment