Skip to content

Commit bfa410d

Browse files
author
John Richard Chipps-Harding
authored
Optimized WebGL Check (#14)
1 parent 68ae59b commit bfa410d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project are documented in this file.
44

5+
## 0.0.3
6+
7+
- Changed: Optimized WebGL Check.
8+
59
## 0.0.2
610

711
- Added: Ability to pass styles in.

src/utils.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
export const getDevicePixelRatio = () => {
2-
if (typeof document === "undefined") return 1;
3-
return devicePixelRatio || 1;
4-
};
1+
let supported = undefined;
52

63
export const isWebGlSupported = () => {
74
if (typeof document === "undefined") return false;
8-
return !!document.createElement("canvas").getContext("webgl");
5+
if (supported === undefined) {
6+
supported = !!document.createElement("canvas").getContext("webgl");
7+
}
8+
return supported;
9+
};
10+
11+
export const getDevicePixelRatio = () => {
12+
if (typeof document === "undefined") return 1;
13+
return devicePixelRatio || 1;
914
};

0 commit comments

Comments
 (0)