Created
February 19, 2011 01:39
-
-
Save rwaldron/834742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="renderer.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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