Scittle Service Worker Template

July 1, 2025 ยท View on GitHub

This repository demonstrates how to use a service worker with Scittle.

You can also clone this repo and use it directly as a template.

How to use

To add a Scittle-powered service worker to your project:

  1. Copy scittle-sw.js to your project's root directory.

  2. Create your service worker logic in a ClojureScript file (e.g., sw.cljs).

  3. Register the service worker in your main HTML file (e.g., index.html) by adding a script tag.

    <script>
      if('serviceWorker' in navigator) {
        navigator.serviceWorker.register('scittle-sw.js?libs=promesa,js-interop&script=sw.cljs');
      }
    </script>
    

scittle-sw.js Configuration

The scittle-sw.js script is a generic loader for any Scittle service worker script. It is configured via URL query parameters.

  • script: The path to your ClojureScript service worker file. Defaults to sw.cljs.
  • libs: A comma-separated list of Scittle libraries to load in the service worker context (e.g., promesa, reagent, js-interop).