Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

service worker

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

Comment

service worker.js

if ('serviceWorker' in navigator) {  window.addEventListener('load', function() {    navigator.serviceWorker.register('/sw.js').then(function(registration) {      // Registration was successful      console.log('ServiceWorker registration successful with scope: ', registration.scope);    }, function(err) {      // registration failed :(      console.log('ServiceWorker registration failed: ', err);    });  });}
Comment

service worker

const filter = {
  url: [
    {
      urlMatches: 'https://www.google.com/',
    },
  ],
};

chrome.webNavigation.onCompleted.addListener(() => {
  console.info("The user has loaded my favorite website!");
}, filter);
Comment

PREVIOUS NEXT
Code Example
Javascript :: particle js 
Javascript :: react navigation 4 
Javascript :: how to rerender a page in React when the user clicks the back button 
Javascript :: javascript regular expression end of string 
Javascript :: work with query string javascript 
Javascript :: js pass variable from iframe to parent window 
Javascript :: call function 
Javascript :: javascript map() method 
Javascript :: modules.exports javascript 
Javascript :: js chrome extension get current url 
Javascript :: reverse integer in for javascript 
Javascript :: javascript filter method 
Javascript :: jquery callback function example 
Javascript :: Importing From Export Default Module 
Javascript :: javascript pass this to callback 
Javascript :: sweet alert 2 
Javascript :: how to make an if statement in javascript 
Javascript :: what is promise in javascript 
Javascript :: how to call a function javascript 
Javascript :: javascript templates 
Javascript :: jquery get element attribute 
Javascript :: how to sort string alphabetically in javascript 
Javascript :: vue prop using variable 
Javascript :: javascript debugging 
Javascript :: validate decimal number with 6 decimal digits javascript 
Javascript :: ?. in javascript 
Javascript :: new function javascript 
Javascript :: open source 
Javascript :: js vue array change position 
Javascript :: tailwind only dropdown 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =