D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
w8r
Full window
Github gist
Transferrable objects demo
Made with blockup
<!DOCTYPE html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> <title>Big Data In Worker Example</title> <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="dist.css"> <body> <h1>Big Data (using transferable objects) In Web Worker Example</h1> <details> <summary>What is 'Big Data' and Web Worker got to do with each other?</summary> <div> TODO... <p>This demo illustrates <a href="https://dev.w3.org/html5/spec/common-dom-interfaces.html#transferable-objects" target="_blank">transferable objects</a>. Transferable objects are objects that are not copied (e.g. using something like <a href="https://updates.html5rocks.com/2011/09/Workers-ArrayBuffer" target="_blank">structured cloning</a>). Instead, the data is transferred from one context to another. The 'version' from the calling context is no longer available once transferred to the new context. For example, when transferring an <code>ArrayBuffer</code> from main app to Worker, the original <code>ArrayBuffer</code> from the main thread is cleared and no longer usable. This vastly improves performance of sending data to a Worker. </p> <p>This demo sends a 32MB <code>ArrayBuffer</code> to a worker and back using a prefixed version of <code>postMessage()</code> that supports transferable objects: <code><a href="https://dev.w3.org/html5/workers/#dedicated-workers-and-the-dedicatedworkerglobalscope-interface" target="_blank">webkitPostMessage()</a></code>. If your browser doesn't support transferables, the sample falls back to old-skool structured cloning.</p> <p><b>Support:</b> Chrome Dev Channel 17+</p> </div> </details> <section> <p><a href="https://dev.w3.org/html5/spec/common-dom-interfaces.html#transferable-objects" target="_blank">Transferable Objects</a> are lightning fast! The prefixed <code>[window|worker].webkitPostMessage()</code> now supports sending an <code>ArrayBuffer</code> as a transferable.</p> <button onclick="test(true);">Run test with transferable objects</button> <button onclick="test(false);">Run test with COPY of objects</button> <pre id="result"></pre> </section> <script src="dist.js"> </script> </body> </html>