service worker is javascript file that run every time.It keeps running even you
close the browser.Due to this we can send push notification,offline mode.
//Register our service worker in index.html
<script>
if('serviceWorker' in navigator){
window.addEventListener('load', ()=> {
//registering of serviceWorker.
navigator.serviceWorker('./serviceworker.js')
.then((reg)=> console.log("Success:", reg.scope));
.catch((err)=> console.log("Failure: ", err));
})}
<script>
everything ok then we will see Sucess: localhost:3000 in console of browser