moxwebgpu · Developer integration

Put browser GPU compute and training into any website — no npm, no backend, no adapter code

← Back to the demo · GitHub

1 Embed in any website in three lines

Drop a <script> tag into your page and your visitors GPU computes right away:
<script src="https://mox-site.pages.dev/webgpu/moxwebgpu.browser.js"></script>
<script>
  MoxWebGPU.mox.init().then(gpu => {
    gpu.tensor([1, 2, 3]).add(1).sum().then(r => console.log('result =', r));
  });
</script>

2 Several ways to include it

CDN · global
IIFE bundle attached to window.MoxWebGPU — the simplest option:
<script src="https://mox-site.pages.dev/webgpu/moxwebgpu.browser.js"></script>
<script>
  const gpu = await MoxWebGPU.mox.init();
</script>
npm
Available after publishing (for now use the CDN):
npm i @mox/moxwebgpu

import { mox } from '@mox/moxwebgpu';
const gpu = await mox.init();
ESM CDN
After publishing you can import directly (esm.sh / unpkg):
import { mox } from 'https://esm.sh/@mox/moxwebgpu';
const gpu = await mox.init();
Edge bundling
No native dependencies — runs directly on Cloudflare Workers:
esbuild worker.ts --bundle \
  --format=esm --outfile=dist/worker.js

3 Run it right here (on your GPU)

🧠 Autodiff · live training

Train linear regression y≈2x+1 in the browser with a live loss curve (backprop on the GPU)
Press the button above to start

⚡ Matrix multiplication

[64×64] · [64×64], tiled with 16×16 workgroups
Waiting to run…

🔗 Tensor chaining

add → relu → mul → sum, lazily evaluated and dispatched once
Waiting to run…

Initializing WebGPU…