October 2017
Intermediate to advanced
302 pages
7h 27m
English
Checking whether the user's browser can handle service workers is very easy. In our script tag, we'll add a simple if statement:
<script> if ('serviceWorker' in navigator) { // register } else { console.log('service worker is not supported'); }</script>
Here, we check the window.navigator object for any service worker support. The navigator can also be used (via its userAgent property) to check what browser the user has, though we won't need that here.
Read now
Unlock full access