title: Is a Web Worker faster than running a script?
body: <p>I was tasked with creating a dedicated webworker instance on each page to handle sending a server request on a given interval regardless of what page the user is on. Since this must work for any browser, a shared webworker was not an option (hence why it must be loaded for each page).</p>
  
  <p>I created a script, thinking that I had been creating a worker, but I was informed recently that workers were not actually being created, though the script was doing the intended function of the webworker.</p>
  
  <p>The basic function of the webworker was this:</p>
  
  <pre><code>onPageLoad {
  
      function sendHeartbeat() {
          sendRequest(URL);
      }
  
      function startHeartbeat() {
          if(timeToSendHeartbeat) {
               sendHeartbeat();
          } else {
               setInterval(timeRemaining, sendHeartbeat());
          }
      }
  }
  </code></pre>
  
  <p>This got me to thinking about whether or not using a webworker was even the best choice. Is there some inherent advantage to using a webworker that I am missing? Is using a webworker no more efficient than attaching a script to each page and running it as is? Or is this application just not suited for a webworker to begin with?</p>