Skip to content

Instantly share code, notes, and snippets.

@thomasdarimont
Created August 18, 2021 21:37
Show Gist options
  • Save thomasdarimont/55c843d181c957ea2e5811822886bfb5 to your computer and use it in GitHub Desktop.
Save thomasdarimont/55c843d181c957ea2e5811822886bfb5 to your computer and use it in GitHub Desktop.
Inline WebWorker example
let code = `self.onmessage = msg => { console.log("Worker: %s", msg.data.text)}`;
const worker = new Worker("data:,"+code);
worker.postMessage({text: 'Hello from main thread!'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment