However, this morning I saw a tweet from Jake Archibald which made me think about my current CTM check.
if (!('visibilityState' in document)) return; A nice way to prevent your JS running in IE<10 and Android WebKit http://t.co/yjbUnyaobV
— Jake Archibald (@jaffathecake) February 26, 2015
While the check mentioned by Jake is great, I immediately thought about extending it and adding a check for ServiceWorker to improve performance for browsers supporting it and for adding offline support. So here is my new check I will use in most of my projects from now on:
If you are unfamiliar with ServiceWorker, I recommend this interactive introduction and if you are searching for a way to generate service worker code, I can recommend this node module that will precache specific resources.