Skip to content

Instantly share code, notes, and snippets.

@BKcore
Created November 22, 2013 01:00
Show Gist options
  • Save BKcore/7592893 to your computer and use it in GitHub Desktop.
Save BKcore/7592893 to your computer and use it in GitHub Desktop.
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) {
// e.data == 'msg from worker'
};
worker.postMessage(); // Start the worker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment