class ServiceWorker implements ExtenderInterface
Methods
Adds a script to the forum's service worker, for example to show push notifications. A browser keeps only one service worker for the forum, so core and every extension share it. An extension that registers a worker of its own at the forum's scope is replaced by core's whenever core's is on, so it should add its script here instead.
Details
at
line 39
ServiceWorker
js(string $file)
Adds a script to the forum's service worker, for example to show push notifications. A browser keeps only one service worker for the forum, so core and every extension share it. An extension that registers a worker of its own at the forum's scope is replaced by core's whenever core's is on, so it should add its script here instead.
The script runs after core's, in a function of its own, so it can't be a module. It's loaded with importScripts(), so a script that throws or doesn't parse only stops itself: core's and other extensions' keep running. Core's answers page loads, to show an offline page when they fail, so a script shouldn't answer them too. ```php (new Extend\ServiceWorker()) ->js(__DIR__.'/js/dist/sw.js') ```