Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created February 19, 2011 01:39
Show Gist options
  • Save rwaldron/834742 to your computer and use it in GitHub Desktop.
Save rwaldron/834742 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="renderer.js"></script>
</head>
<body>
</body>
</html>
document.addEventListener( "DOMContentLoaded", function() {
var worker = new Worker( "worker.js" );
worker.addEventListener( "message", function( event ) {
var data = event.data;
// received from the worker
console.log( data );
// > "Hello julian"
});
// send to the worker
worker.postMessage("julian");
}, false);
onmessage = function( event ) {
postMessage( "Hello " + event.data );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment