I'm trying to find different methods to run code in the background in populer browsers. Each method is described in a seperate file.
-
Simple
Interval is throttled to once per second maximum, when the tab is not marked as visible. This is the case when another tab is in focus or the browser windows is minimized.
-
Web worker
Web worker implementation1 of setInterval. By using a web worker, we can circumvent the throttling in some browser and can execute our callback more often. When the tab is closed, the worker gets terminated.
-
Service worker
Service workers can use setInterval to run concurrently in the background, even when the spawning tab is closed, but there is no guarantee, that the Browser kill the service worker.
Puppeteer allows tracing of web pages. See https://pptr.dev/#?product=Puppeteer&version=v1.16.0&show=api-class-tracing
The resulting json file can then be analysed in Timeline Viewer or Chrome Dev Tools.
https://chromedevtools.github.io/timeline-viewer/
npm run trace
- Puppeteer
- Chrome DevTools Timeline Viewer
- Catapult Tracing Frontend
- Catapult Source Code
- Timeline Event Reference
- Trace Event Format Specification
- Chrome Background Tabs and Offscreen Frames: Future Plans
- Chrome Background Tabs Throttling
- WHATWG HTML5 Spec Timers and User Prompts
- WebTAP: Princeton Web Transparency & Accountability Project