OffscreenCanvas: OffscreenCanvas() constructor
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Note: This feature is available in Web Workers.
The OffscreenCanvas() constructor returns a newly instantiated OffscreenCanvas object.
Syntax
js
new OffscreenCanvas(width, height)
Parameters
Examples
This example creates a new offscreen canvas using the OffscreenCanvas() constructor.
We then initialize a WebGL context on it using the getContext() method.
js
const offscreen = new OffscreenCanvas(256, 256);
const gl = offscreen.getContext("webgl");
Specifications
| Specification |
|---|
| HTML> # dom-offscreencanvas-dev> |
Browser compatibility
Loading…
See also
OffscreenCanvas, the interface this constructor belongs to