Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdeepkhalsa/eee504e41d817490833e to your computer and use it in GitHub Desktop.
Save jasdeepkhalsa/eee504e41d817490833e to your computer and use it in GitHub Desktop.
Cutting the Mustard Feature Detection
// From: http://responsivenews.co.uk/post/18948466399/cutting-the-mustard
if('querySelector' in document && 'localStorage' in window && 'addEventListener' in window) {
// Load the enhanced app:
/*
HTML5 browsers:-
IE9+
Firefox 3.5+
Opera 9+ (and probably further back)
Safari 4+
Chrome 1+ (I think)
iPhone and iPad iOS1+
Android phone and tablets 2.1+
Blackberry OS6+
Windows 7.5+ (new Mango version)
Mobile Firefox (all the versions we tested)
Opera Mobile (all the versions we tested)
*/
}
else {
// Load the basic app:
/*
HTML4 browsers:-
IE8-
Blackberry OS5-
Nokia S60 v6-
Nokia S40 (all versions)
All other Symbian variants
Windows 7 phone (pre-Mango)
…and many more that are too numerous to mention
*/
}
// From: https://justmarkup.com/log/2015/02/26/cut-the-mustard-revisited/
if ('visibilityState' in document) {
// Modern browser. Let's load JavaScript
if ('serviceWorker' in navigator) {
// Let's add offline support
navigator.serviceWorker.register('sw.js', {
scope: './'
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment