Newly availableHelpful for binary data pipelines with uncertain sizes. Keep fixed buffers when the size is already predictable.

Overview

Resizable buffers allow ArrayBuffer and SharedArrayBuffer instances to grow or shrink within configured limits. They reduce the need to allocate a brand-new buffer for every size change.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
111
111
128
16.4
111
16.4
Built-in object
ArrayBuffer.ArrayBuffer.maxByteLength option

`maxByteLength` option

111
111
128
16.4
111
16.4

The resizable accessor property of ArrayBuffer instances returns whether this array buffer can be resized or not.

111
111
128
16.4
111
16.4

The resize() method of ArrayBuffer instances resizes the ArrayBuffer to the specified size, in bytes.

111
111
128
16.4
111
16.4
SharedArrayBuffer.SharedArrayBuffer.maxByteLength option

`maxByteLength` option

111
111
128
16.4
111
16.4

The grow() method of SharedArrayBuffer instances grows the SharedArrayBuffer to the specified size, in bytes.

111
111
128
16.4
111
16.4

The growable accessor property of SharedArrayBuffer instances returns whether this SharedArrayBuffer can be grow or not.

111
111
128
16.4
111
16.4

The maxByteLength accessor property of SharedArrayBuffer instances returns the maximum length (in bytes) that this SharedArrayBuffer can be grown to.

111
111
128
16.4
111
16.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
const buffer = new ArrayBuffer(8, { maxByteLength: 64 });
buffer.byteLength; // 8

buffer.resize(32);
buffer.byteLength; // 32

Live demo

Create a resizable ArrayBuffer

Allocate a resizable buffer when the option is supported.

JavaScript
Output
Press the Run button

Resize a buffer

Grow a resizable buffer and inspect the new typed-array view length.

JavaScript
Output
Press the Run button

Guard resize at runtime

Use feature detection before relying on buffer resizing helpers.

JavaScript
Output
Press the Run button

Use cases

  • Growing binary payloads

    Expand a buffer as incoming data arrives instead of repeatedly copying into larger allocations.

  • Adaptive parsers

    Handle unknown payload sizes more cleanly in streaming or chunked binary workflows.

Cautions

  • Resizable memory adds lifecycle complexity, so document when and why buffers are allowed to grow or shrink.
  • Views over the same buffer can be affected by resizing behavior, which makes ownership rules important.

Accessibility

  • No direct accessibility effect, but more efficient binary handling can improve loading stability for user-facing experiences.
  • Do not let optimization complexity obscure error handling or fallback states.

Powered by web-features