Skip to content

Instantly share code, notes, and snippets.

@joshuamabina
Created April 13, 2018 13:50
Show Gist options
  • Save joshuamabina/8ca5ee2b3f557fa0431b56bfc870e7a3 to your computer and use it in GitHub Desktop.
Save joshuamabina/8ca5ee2b3f557fa0431b56bfc870e7a3 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Hello world from a worker</title>
</head>
<body>
<script charset="utf-8">
var worker = new Worker('worker.js');
worker.addEventListener('message', function(e) {
console.log('Worker said:', e.data);
}, false);
worker.postMessage('Hello worker');
</script>
</body>
</html>
self.addEventListener('message', function(e) {
console.log('World said:', e.data);
self.postMessage(e.data);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment