OffscreenCanvas()

Experimental

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The OffscreenCanvas() constructor returns a newly instantiated OffscreenCanvas object.

Syntax

new OffscreenCanvas(width, height);

Parameters

width
The width of the offscreen canvas.
height
The height of the offscreen canvas.

Examples

This example creates a new offscreen canvas using the OffscreenCanvas() constructor. We then initialize a WebGL context on it using the getContext() method.

let offscreen = new OffscreenCanvas(256, 256);
let gl = offscreen.getContext('webgl');

Specifications

Specification
HTML Standard (HTML)
# dom-offscreencanvas-dev

Browser compatibility

BCD tables only load in the browser

See also