<script type="text/js-worker" id="answerUltimateQuestion"> onmessage = function (msg) { // TODO: long running code that uses msg.data to figure out answer to everything postMessage(42); }; </script> <button id="ask">What is the answer?</button>