timeweb
timeweb copied to clipboard
[FEATURE REQUEST] Any plan to make it work with webworker
It's an interesting idea technology wise, though I haven't encountered too many projects that use time-based web workers. Is there a specific site or use case that you have in mind? Without a use case, it's unclear whether a new feature would adequately support it.
Some things to consider to implement this feature:
requestAnimationFrame,setTimeout,setInterval,Date, andperformancefunctions are implemented in Web Workers- To sync with the parent web page (running at least in a regular web browser, and not a headless one), there'd need to be some coordination.
postMessageis the traditional way of doing this (with a message channel to notify the parent when it's finished), but automatically doing this may interfere with existing code. Headless browsers like puppeteer or playwright, may already have ways of evaluating code in a web worker context (puppeteer hasWebWorker.evaluate, and playwright hasWorker.evaluate) - Workers traditionally import code via the
importScriptsfunction, which may serve as the way to includetimewebinto a worker. For puppeteer and playwright, while there are ways to evaluate code inside web workers, there doesn't seem to be a way to evaluate it before any other code is run (contrasted withpage.evaluateOnNewDocumentorpage.addInitScriptwhich runs code on web pages before any other code is run)