title: Web Workers - Transferable Objects for JSON
body: <p>HTML 5 Web workers are very slow when using worker.postMessage on a large JSON object.
  I'm trying to figure out how to transfer a JSON Object to a web worker - using the 'Transferable Objects' types in Chrome, in order to increase the speed of this. </p>
  
  <p>Here is what I'm referring to and appears it should speed this up quite a bit:
  <a href="http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast" rel="noreferrer">http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast</a></p>
  
  <p>I'm having trouble finding a good example of this (and I don't believe I want to use an ArrayBuffer). Any help would be appreciated.</p>
  
  <p>I'm imagining something like this:</p>
  
  <pre><code>worker = new Worker('workers.js');
  
  var large_json = {};
  for(var i = 0; i &lt; 20000; ++i){
     large_json[i] = i;
     large_json["test" + i] = "string";
  };
  
  //How to make this call to use Transfer Objects? Takes approx 2 seconds to serialize this for me currently.
  worker.webkitPostMessage(large_json);
  </code></pre>