Skip to content

Commit f38fcf3

Browse files
committed
Optimized Canvas2D performance by setting willReadFrequently to true in checkSupport()
The willReadFrequently attribute is now explicitly set to true when obtaining the 2D rendering context for the canvas. This informs the browser that getImageData will be used frequently, potentially enhancing the speed of multiple readback operations.
1 parent a6e4745 commit f38fcf3

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

background-check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
canvas = document.createElement('canvas');
209209

210210
if (canvas && canvas.getContext) {
211-
context = canvas.getContext('2d');
211+
context = canvas.getContext('2d', { willReadFrequently: true });
212212
supported = true;
213213
} else {
214214
supported = false;

background-check.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)