title: loading Web Workers in bookmarklets
body: <p>I get my web worker working in a bookmarklet. The code resides in the same folder as the calling code, I dont explicitly load up the worker code as it is loaded using the <code>importScripts</code> function in the worker.js file.</p>
  
  <p>I create the worker like so</p>
  
  <pre><code>    if(typeof(Worker) !== "undefined") {
          worker = new Worker('worker.js');
      }
  </code></pre>
  
  <p>then I call the worker like so </p>
  
  <pre><code>    worker.postMessage({'cmd': 'start', 'grabRate': grabRate});
  </code></pre>
  
  <p>which should call the function in my worker file</p>
  
  <pre><code>self.addEventListener('message', function(e) {
      console.log("worker message");
    var data = e.data;
    switch (data.cmd) {
      case 'start':
        console.log("start from worker");
  ...
  </code></pre>
  
  <p>I don't see any debug messages in the console telling me that the 'message' has been called in the worker. I only load the code that calls the worker.js (in the bookmarklet loader function) since that is loaded by the <code>new Worker</code> function (If I also included the files in the loader function I could see the file but the function still isn't called). I cant see the worker files in the Chrome debug sources list or the other files loaded using the <code>importScripts</code> function.</p>