Skip to content

Instantly share code, notes, and snippets.

@alexzaporozhets
Created January 8, 2014 16:26
Show Gist options
  • Save alexzaporozhets/8319591 to your computer and use it in GitHub Desktop.
Save alexzaporozhets/8319591 to your computer and use it in GitHub Desktop.
Web Worker for Blob string
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) {
alert(e.data)
};
worker.postMessage('data');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment