Skip to Content

registerServiceWorker()

Functionality for registering and communicating to the Nebula service worker.

JavaScript February 19, 2018

Usage

This function runs automatically, so it is not called manually. Is this incorrect?

Demo


Waiting for JavaScript to load...

Open this page in additional tab(s) to send a message between them:

Additional Notes

To install the Nebula Service Worker, find the sw.js file in the Nebula Child resources directory and move it to the root directory. Then, enable Service Worker in Nebula Options.

If you need to override the name and/or location of the file, override the sw_location() function (documentation here).

When using an SSL, Nebula sets a Content Security Policy (CSP) header to upgrade all http protocol requests to https.

This function is called from nebulaServiceWorkerInit() which either registers the service worker immediately (if it has been installed already) or waits for the user to scroll before installing (to prevent downloading all of the resources on initial page load).

Source File

Located in /assets/js/nebula.js on line 153.

Note: This function contains 49 to-do comments.

Override

To override or disable this JavaScript function, simply redeclare it with the exact same function name.

JavaScript
nebula.registerServiceWorker = function(){
    //Write your own code here, leave it blank, or return false.
}