Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

27 lines (23 sloc) 631 Bytes
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple synchronous JavaScript example</title>
</head>
<body>
<button>Click me</button>
<script>
const btn = document.querySelector('button');
const worker = new Worker('worker.js');
btn.addEventListener('click', () => {
worker.postMessage('Go!');
let pElem = document.createElement('p');
pElem.textContent = 'This is a newly-added paragraph.';
document.body.appendChild(pElem);
});
worker.onmessage = function(e) {
console.log(e.data);
}
</script>
</body>
</html>
You can’t perform that action at this time.