webnn

Detect WebNN support and initialize an MLContext for in-browser ML acceleration.

46|4|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/webmaxru/agent-skills --skill webnn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webnn
Source: https://github.com/webmaxru/agent-skills/tree/main/skills/webnn
Command: npx skills add https://github.com/webmaxru/agent-skills --skill webnn

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

WebNN enables in-browser machine learning with local acceleration, reducing reliance on server-side inference and enabling private, offline-capable ML in web apps.

Core Features & Use Cases

  • Detects WebNN support and creates a secure MLContext with configurable power and acceleration preferences.
  • Provides a guided integration path including tensor creation, write/read, graph building, dispatch, and context loss handling.
  • Use Case: Add in-browser ML to a web app to run models locally, fallback to non-WebNN runtimes when unavailable, and debug integration issues.

Quick Start

Detect WebNN support and initialize a context with a simple graph to validate the setup.

Frequently Asked Questions about webnn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect WebNN support and create an MLContext in a web app?

To use WebNN for in-browser ML acceleration, detect navigator.ml support and initialize an MLContext within a secure context. You can configure context options like powerPreference and accelerated to optimize local inference.

What is WebNN used for in browser-based machine learning?

WebNN is used for in-browser machine learning to enable local hardware acceleration. It reduces reliance on server-side inference by allowing web apps to load models, construct graphs with MLGraphBuilder, and execute tensor I/O directly on the client.

How do I handle fallback to non-WebNN runtimes when browser inference is unavailable?

When WebNN is unavailable, you can fallback to non-WebNN runtimes to maintain browser inference capabilities. This ensures your web app continues functioning by dispatching tensors through alternative local execution paths.

Can I reuse MLGraph and tensors for in-browser ML execution?

Yes, you can reuse MLGraph and tensors during in-browser ML execution to optimize performance. The WebNN integration path supports graph construction, tensor write/read operations, and proper resource cleanup to prevent memory leaks.

Does WebNN require a secure context for MLContext initialization?

Yes, WebNN requires a secure context for MLContext initialization to ensure safe in-browser machine learning. Enforcing secure contexts protects local model loading, tensor dispatch, and graph construction operations within the browser.

Why is my WebNN context loss happening during local model loading?

WebNN context loss can occur during local model loading due to system resource constraints. You should monitor context loss events and implement proper cleanup procedures to dispose of MLGraph and tensor resources when the MLContext is lost.