title: Unable to install service worker on Safari iOS
body: <p>I'm trying to install a service worker on Safari on iOS 12.1:</p>
  
  <pre><code>if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('/sw.js');
      alert('Success');
  } else {
      alert('Fail');
  }
  </code></pre>
  
  <p>But instead of seeing <code>Success</code>, I get <code>Fail</code>.</p>
  
  <p>When trying to register the service worker without checking for support:</p>
  
  <pre><code>navigator.serviceWorker.register('/sw.js');
  </code></pre>
  
  <p>The browser simply stops JavaScript execution. I've tested the service worker on Firefox on desktop, and everything works fine.</p>
  
  <p>Am I doing something wrong? According to <a href="https://jakearchibald.github.io/isserviceworkerready/" rel="nofollow noreferrer">Is service worker ready?</a>, Safari on iOS supports service workers. Further, in Safari settings I have <code>Service Workers</code> enabled within experimental features. How can I use service workers on iOS?</p>