← Back to release summary

Streams API: transferable streams

Category
JavaScript
Type
New or changed feature
Status
Enabled by default (Chrome 87)
Intent stage
Shipped

Summary

The streams APIs provide ubiquitous, interoperable primitives for creating, composing, and consuming streams of data. A natural thing to do with a stream is to pass it to a web worker. This provides a fluent primitive for offloading work to another thread. Transferable streams add this capability by allowing ReadableStream, WritableStream, and TransformStream objects to be passed as arguments to postMessage().

Motivation

Offloading work onto a worker is important for a smooth user experience, but the ergonomics can be awkward. Transferable streams solve this problem for streams. Once the stream itself has been transferred, the data is transparently cloned in the background.

Standards & signals

Docs: https://docs.google.com/document/d/1_KuZzg5c3pncLJPFa8SuVm23AP4tft6mzPCL5at3I9M/edit

Samples: https://github.com/whatwg/streams/blob/master/transferable-streams-explainer.md

Explainers: https://github.com/whatwg/streams/blob/master/transferable-streams-explainer.md

View on chromestatus.com