diff --git a/js/web/lib/index.ts b/js/web/lib/index.ts index 41024de108..e3851755a3 100644 --- a/js/web/lib/index.ts +++ b/js/web/lib/index.ts @@ -16,7 +16,7 @@ if (!BUILD_DEFS.DISABLE_WEBGL) { if (!BUILD_DEFS.DISABLE_WASM) { const wasmBackend = require('./backend-wasm').wasmBackend; - if (!BUILD_DEFS.DISABLE_WEBGPU) { + if (!BUILD_DEFS.DISABLE_WEBGPU && typeof navigator !== 'undefined' && navigator.gpu) { registerBackend('webgpu', wasmBackend, 5); } registerBackend('cpu', wasmBackend, 10);