Skip to content

Instantly share code, notes, and snippets.

@zackdouglas
Created October 24, 2014 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackdouglas/7675fb9a7ed5c8034e29 to your computer and use it in GitHub Desktop.
Save zackdouglas/7675fb9a7ed5c8034e29 to your computer and use it in GitHub Desktop.
Inline Web worker
var blob = new Blob([
"onmessage = function(e) { postMessage('msg from worker'); }"]);
// Obtain a blob URL reference to our worker 'file'.
var blobURL = window.URL.createObjectURL(blob);
var worker = new Worker(blobURL);
worker.onmessage = function(e) {
console.dir(e);
};
worker.postMessage(); // Start the worker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment