Browse Source

Determine service worker script path based on path of main script.

master
Dan 1 year ago
parent
commit
cc963ebce3
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      src/index.js

+ 3
- 1
src/index.js View File

@@ -10,7 +10,9 @@ function App() {

function create() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/ipfs/fetcher.js')
const this_script_url = document.currentScript.src;
const base_script_url = this_script_url.slice(0, this_script_url.lastIndexOf('/'))
navigator.serviceWorker.register(base_script_url + '/fetcher.js')
.then((registration) => {
console.log('registered the service worker successfully')


Loading…
Cancel
Save