Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usually the UI) thread to run without being blocked/slowed down.
Web Workers API
41–47 of 47 posts
Re: Web Workers API
#42is web worker really good for some costly processes? would it really be useful for a dashboard with sample instant data flow?
We used web workers to shift a lot of processing off of the main thread. They helped in keeping the UI feeling responsive and less laggy.
Re: Web Workers API
#43The fact that creating a worker requires you to pass a module (file) name makes them extremely unergonomic to use. This is clearly visible in the lack of any library ecosystem around them. We don't have any highly used threadpool or executor libraries using workers. Everyone seems to be manually setting up a worker and setting up the job scheduling logic from scratch. All the boilerplate and restrictions really restr…
https://stackoverflow.com/a/6454685/265521
And do you have a reference for the caching issue? I tried to Google it but all I found was people saying that web workers were cached too much, not that they aren't cached at all.
Re: Web Workers API
#44Re: Web Workers API
#45Earlier quoted context omitted.
I should check what's the status with Atomics.wait on Chrome, currently it seems to work fine under both Node and Deno. I'll test out the regex thing in the following days as I need it for that exact use case, I just assumed killing the web worker would... work, hopefully that's the case otherwise I'm back to square 0 :D --- Edit: MDN says: "The terminate() method of the Worker interface immediately terminates the Wo…
Worker.terminate() aborts the currently running script evaluation, see https://html.spec.whatwg.org/multipage/workers.html#dom-work... → https://html.spec.whatwg.org/multipage/workers.html#terminat... → https://html.spec.whatwg.org/multipage/webappapis.html#abort... , but that’s a fairly fuzzy definition, and it’s not generally reasonable to expect that to interrupt a currently executing piece of native code, because…
Re: Web Workers API
#46Earlier quoted context omitted.
Worker.terminate() aborts the currently running script evaluation, see https://html.spec.whatwg.org/multipage/workers.html#dom-work... → https://html.spec.whatwg.org/multipage/workers.html#terminat... → https://html.spec.whatwg.org/multipage/webappapis.html#abort... , but that’s a fairly fuzzy definition, and it’s not generally reasonable to expect that to interrupt a currently executing piece of native code, because…
At least in Chrome it works as advertised: https://twitter.com/fabiospampinato/status/14683093104804741...
Seems to work in Chromium, though it looks like it might be taking a second or two to actually terminate it. It’s a bit harder to tell if it works in Firefox, because Firefox kills the regular expression within five seconds with the error from RegExpBuiltinExec “too much recursion”, but I think it is, and probably faster than Chromium, though it’s hard to be certain when just doing the lazy check of CPU usage at one second granularity.
Re: Web Workers API
#47Earlier quoted context omitted.
At least in Chrome it works as advertised: https://twitter.com/fabiospampinato/status/14683093104804741...
Syntax errors there, t.co mangulation of e.data. Seems to work in Chromium, though it looks like it might be taking a second or two to actually terminate it. It’s a bit harder to tell if it works in Firefox, because Firefox kills the regular expression within five seconds with the error from RegExpBuiltinExec “too much recursion”, but I think it is, and probably faster than Chromium, though it’s hard to be certain wh…
Interesting! They must have changed something because when I published that the code looked alright, albeit with some stuff linkified.