WebNN Origin Trials Registration
The Web Neural Network API (WebNN) is now available for testing through Origin Trials on Chrome and Edge browsers. Origin Trials allow developers to experiment with new web platform features in production environments before they become standard.
What is an Origin Trial?
An Origin Trial gives you access to experimental features for your origin, allowing real users to interact with the new functionality. This helps browser vendors gather feedback and validate features before making them available to all users.
Prerequisites
Before registering for the WebNN Origin Trial, ensure you have:
- A website or web application that will use the WebNN API
- Administrative access to modify HTTP headers or HTML on your site
- A valid origin (protocol + hostname + port)
Registration Steps
For Google Chrome
-
Navigate to the Chrome Origin Trials page
-
Sign in with your Google account
You’ll need to authenticate to register for the trial
-
Provide your origin
Enter the origin where you plan to use WebNN (e.g.,
https://example.com)- The origin must include the protocol (https://)
- Wildcards are supported for subdomains (e.g.,
https://*.example.com)
-
Submit your registration
Review and accept the terms, then submit your registration
-
Receive your trial token
You’ll receive a unique token for your origin
For Microsoft Edge
-
Navigate to the Edge Origin Trials page
-
Sign in
Authenticate to access the trial registration
-
Provide your origin
Enter the origin where you plan to use WebNN
-
Submit your registration
Accept the terms and complete your registration
-
Receive your trial token
You’ll receive a unique token for your origin
Implementing the Trial Token
Once you’ve received your trial token, you need to add it to your website. There are three methods:
Method 1: Meta Tag
Add a meta tag to the <head> section of your HTML:
<meta http-equiv="origin-trial" content="YOUR_TOKEN_HERE">You can insert both meta tags into the
<head>section of HTML document, one for each browser’s token. The browsers are designed to ignore tokens they don’t understand, so you can safely include both.
This method is useful when you cannot modify server headers.
Method 2: HTTP Header
Add the token as an HTTP response header:
Origin-Trial: YOUR_TOKEN_HEREThis method applies the token to all resources served from your origin.
Method 3: Provide a token programmatically
Inject a token with JavaScript:
const otMeta = document.createElement('meta');
otMeta.httpEquiv = 'origin-trial';
otMeta.content = 'TOKEN_GOES_HERE';
document.head.append(otMeta);Verifying Your Setup
To confirm the Origin Trial is active:
- Open your website in Chrome or Edge
- Open
DevTools(F12) - Navigate to the
Consoletab - Check for any Origin Trial related messages
- Verify that
navigator.mlis available:
if ('ml' in navigator) {
console.log('WebNN API is available');
} else {
console.log('WebNN API is not available');
}Key Considerations
Trial Duration
- Origin Trials have a limited duration
- Monitor the trial status on the respective browser’s Origin Trials page
- Plan to remove or update tokens when the trial ends
Browser Support
- Chrome: 146 to 148
- Edge: 146 to 148
- The feature is experimental and subject to change
User Opt-Out
- Users can disable Origin Trials in their browser settings
- Your code should gracefully handle cases where WebNN is unavailable
Origin Trial Feedback
As a trial participant, your feedback is valuable and helps shape the future of the WebNN API:
- Submit feedback through the origin trial site: You can provide private feedback directly through the Chrome Origin Trials dashboard. This feedback is confidential and only available to a limited group of people on the Chrome team.
- Public community feedback
Token Renewal
- When your trial token approaches expiration, you will receive an email notification with a renewal link
- To renew your token, you will be asked to submit feedback about your experience with the trial
- This feedback helps browser vendors understand how the feature is being used and what improvements are needed
Example Usage
Once the Origin Trial is active, you can begin using the WebNN API:
async function initializeWebNN() {
if (!('ml' in navigator)) {
console.error('WebNN is not supported');
return;
}
try {
const context = await navigator.ml.createContext();
// Your WebNN implementation here
} catch (error) {
console.error('Failed to create WebNN context:', error);
}
}
initializeWebNN();Best Practices
- Feature Detection: Always check for WebNN support before using the API
- Fallback Strategy: Implement fallbacks for browsers without WebNN support
- Error Handling: Handle errors gracefully as the API is experimental
- Performance Monitoring: Track performance improvements from WebNN usage
- Security: Only use Origin Trials on HTTPS origins
Getting Help
- Chrome WebNN Issues: Chromium Bug Tracker
- Edge WebNN Issues: Edge Developer Support
Next Steps
After registering and implementing the trial token:
- Test your WebNN implementation thoroughly
- Monitor performance and user experience
- Provide feedback to browser vendors
- Stay informed about trial expiration dates
- Plan for migration to the standard API when available