Transferable ArrayBuffer
Transferable ArrayBuffer support allows ownership of a buffer to move without copying the underlying bytes. It is useful when large binary payloads need to move across workers efficiently.
Overview
Transferable ArrayBuffer support allows ownership of a buffer to move without copying the underlying bytes. It is useful when large binary payloads need to move across workers efficiently.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 114 | 114 | 122 | 17.4 | 114 | 17.4 | |
| Built-in object | ||||||
| The transfer() method of ArrayBuffer instances creates a new ArrayBuffer with the same byte content as this buffer, then detaches this buffer. | 114 | 114 | 122 | 17.4 | 114 | 17.4 |
| The transferToFixedLength() method of ArrayBuffer instances creates a new non-resizable ArrayBuffer with the same byte content as this buffer, then detaches this buffer. | 114 | 114 | 122 | 17.4 | 114 | 17.4 |
Syntax
const buf = new ArrayBuffer(1024);
const transferred = buf.transfer();
buf.byteLength; // 0 (already detached)
transferred.byteLength; // 1024 Live demo
Check transfer support
Inspect whether ArrayBuffer.prototype.transfer exists.
Transfer a buffer when supported
Move the contents into a new buffer without manual copying.
Transfer to a fixed size
Use transferToFixedLength when the runtime exposes the helper.
Use cases
Worker handoff
Move binary data between threads without duplicating the entire payload in memory.
Media and file processing
Pass decoded or transformed buffers through a pipeline while keeping copies to a minimum.
Cautions
- After transfer, the original owner loses access to the buffer, so lifecycle mistakes can cause confusing bugs.
- Explicit transfer semantics are powerful, but they demand clear ownership documentation.
Accessibility
- Faster large-data transfers can help keep document and media processing responsive.
- User-facing progress still needs to reflect the work happening across thread boundaries.
Related links
Powered by web-features