Polyfill for online
and offline
events on WebWorkers
https://issues.chromium.org/issues/40155587
npm i @hazae41/worker-online-polyfill
- ESModules and CommonJS
- No external dependency
ESModules
import "@hazae41/worker-online-polyfill"
CommonJS
require("@hazae41/worker-online-polyfill")
You can import the polyfill in your worker entry file or in a specific file
import "@hazae41/worker-online-polyfill"
self.addEventListener("online", () => console.log("online"))
self.addEventListener("offline", () => console.log("offline"))