This demo illustrates transferable objects.
Transferable objects are objects that are not copied (e.g. using something like structured cloning).
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
ArrayBuffer from main app to Worker, the
ArrayBuffer from the main thread is cleared and no longer usable.
This vastly improves performance of sending data to a Worker.
This demo sends a 32MB
ArrayBuffer to a worker and back using a different signature of
that supports transferable objects:
If your browser doesn't support transferables, the sample falls back to old-skool structured cloning.
Support: Chrome Dev Channel 17+
Transferable Objects are lightning fast! The prefixed
now supports sending an
ArrayBuffer as a transferable.