Created
August 10, 2013 10:43
-
-
Save sudodoki/6199982 to your computer and use it in GitHub Desktop.
See http://tech.pro/tutorial/1487/web-worker-patterns for more info
This file contains hidden or 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> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<p>Open your browser's console to see the results.</p> | |
<script id="worker" type="app/worker"> | |
addEventListener('message', function() { | |
postMessage('Im reading Tech.pro'); | |
}, false); | |
</script> | |
<script> | |
(function() { | |
var blob = new Blob([document.querySelector('#worker').textContent]), | |
url, | |
worker; | |
url = window.URL.createObjectURL(blob); | |
worker = new Worker(url); | |
worker.addEventListener('message', function(e) { | |
console.log(e.data); | |
}, false); | |
worker.postMessage(''); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment