apparently you can create #Web-workers from localhost HTTP URLs, but not file:// URLs, and in I guess Chromium not data: URLs, but you can create Blob URLs in #JS. If HTTP or HTTPS, the MIME type has to be text/javascript. #browsers
on 02023-06-22oh apparently #Web-workers can also use addEventListener on their global scope to listen for message events, and also when you create one you can call that on it
Explanation of #Web-workers in #JS. Normally it's like const w = new Worker('worker.js'), where worker.js defines an onmessage callback which can use a postMessage global to send back too its creator, who can handle it by setting w.onmessage to the appropriate callback. There's a synchronous, blocking importScripts in the worker that takes URLs oof libraries to load. Runtime errors invoke onerror. #browsers
Messaging #Web-workers is fast #performance even without transferable objects, but the test code here is broken #browsers
on 02023-06-22#Web-workers can transfer so-called "transferable objects" to other “agents” in the “cluster” without copying them by listing them in an array passed as a second argument to postMessage; the ArrayBuffer in .buffer of typed arrays like Uint8Array is such a transferable object, as are things like MessagePort, AudioData, and WritableStream. Agents are web workers or the DOM execution context. #JS #wasm #browsers
on 02023-06-22