Menu
Menu Sheet Overlay
Search
Search Sheet

Service Worker Installation

    Service workers are an exciting new web browser feature that provides progressive web apps with app-like superpowers to work offline or receive push notifications.

    Mobify’s service worker must be installed on your website to unlock the full potential of the Mobify Platform.

    NOTE: Mobify provides a cartridge for Salesforce Commerce Cloud (formerly Demandware) to simplify installation.

    Installing the worker #

    Installing the service worker (the worker, for short) requires serving a JavaScript file over HTTPS from the root of your domain:

    1. Find the code for your worker in your project: web/service-worker-loader.js. Copy its contents.
    2. On your server, create a worker file called service-worker-loader.js that is available from the root of your domain. If your domain is example.com, the file must be example.com/service-worker-loader.js.
    3. Paste the worker’s code into this file

    Verifying the installation #

    To verify that the worker is installed correctly:

    1. Open your browser and navigate to the worker over HTTPS. If your domain is example.com, open https://example.com/service-worker-loader.js.
    2. Check the worker opens using HTTPS without errors. Service workers are powerful features that only work over secure connections.
    3. Check the worker is served exactly from the path /service-worker-loader.js without redirection. Redirects break the worker’s scope by changing the URL it is registered from.
    4. Check that the contents of the worker on your server exactly match the contents of the worker in your project
    5. Check the worker is served using the Content Type application/javascript

    A working example #

    You can see an example of a correctly installed worker by opening this URL in your web browser: https://www.merlinspotions.com/service-worker-loader.js

    Merlin's Potions worker is correctly installed

    When does the worker need to be installed? #

    If it’s not possible to install the service worker during development, workarounds are possible.

    But in production, the service worker must be installed correctly. To get help with installation, contact support@mobify.com.