1

I have script that can be downloaded/used as a serverless single html file and mostly do the same as it did when on a server. Parts of it however use web workers. I would like to get these also working server-less. I made a worker via a blob. Web workers without a separate Javascript file?

This solution still only works via server even though no external resources are being used. No errors are thrown. Any thoughts on how to get thread like functionality in a no-server context?

user2856949
  • 317
  • 2
  • 6
  • What does server-less means here? The page is served from which protocol? How do you generate the Worker? Are you listening to its `onerror` event? Except in case of strong CSPs you should be able to run a Worker from a blob:// URL. Can you try this code: `w = new Worker(URL.createObjectURL(new Blob([\`postMessage('works')\`]))); w.onmessage = (e)=>console.log(e.data); w.onerror = console.error;` – Kaiido Mar 03 '21 at 09:08
  • My fault. Your code works, as does mine. I must have fat-fingered my test this morning. Thanks! – user2856949 Mar 03 '21 at 15:41
  • Then please delete this question so people don't waste time trying to figure out what could have happen. – Kaiido Mar 03 '21 at 22:32

0 Answers0