The Origin Trials

Young adult, dystopian thriller or the future of the web? Origin trials are one of the methods that browsers experiment with new web technologies and you should know about them. Being aware of the experiments and taking part in the ones important to you gives you a voice in the future of the web platform.

In this talk we’ll explore what an origin trial is, how you can take part, and what is currently being experimented with on the web. Vigilance is key to protect the web from a potential future dystopia.


The Origin Trial

Phil Nash, Developer Evangelist Twilio

When Phil first wrote the topic, “The Origin Trials” sounded like a dystopian young adult thriller… but since we have quite enough dystopia right now you’ll be glad to know this is a good thing!

You heard earlier about Project Fugu; and that’s what led Phil to the origin trials as well. What Phil has found is that people simply hadn’t heard of origin trial. So it’s important for us to know what that is and how we can use them to be part of the standards process.

Origin trials are designed to help design new APIs that developers actually want to use; and to make sure they are secure and private for users. Origin trials let us test experimental web features with real users.

To understand, let’s go back to 2016 when Firefox released version 49. While not otherwise a huge release, it implemented a large number of -webkit prefixed features… some implemented by other browsers, some implemented in Firefox… all under the webkit prefix. A bit bizarre!

But this was after all the time of vendor prefixes, when new features were tested by shipping prefixed versions. It was popular because it gave early access, but it made really messy, bloated code… or people would only use a prefixed version, or they’d leave out some browsers’ prefixes.

The idea was that devs would try things out behind ugly prefixes but then remove them… but we didn’t. We shipped them. The joy of new things outweighed the caveats.

This ultimately left the web broken in some browsers, which is how you end up with Firefox shipping webkit prefixes. Other browsers like Opera did this too. We ended up with sites dedicated to tracking which prefixes were still necessary.

Developers got better at this over time, using tools like autoprefixer to ship
the right code; or we used polyfills to backport functionality to old browsers.

But what about things that can’t be polyfilled? Native features like file access don’t exist in JavaScript, you can’t polyfill them. We got browser feature flags, so you can turn on new features in the browser to try them out. But this is just for devs to try things on their own machines, users aren’t going to do this.

But what about users? We don’t want to ship potentially dangerous features to users without testing them somehow. This is where origin trials come in – they let us test experimental features with our users.

They currently work in Chrome and Edge.

So you go to the websites…

https://developers.chrome.com/origintrials/
https://developer.microsoft.com/en-us/microsoft-edge/origin-trials/

…and you register which feature you want to try out. Then you get a key that you publish in a meta tag or HTTP header on your website, and your URL is now allowed to use the new feature.

Origin trials have some rules. There is a fixed time limit; the feature can be pulled if implementation rates get too high or there is a security breach; features can change; features may not ship as a standard.

So if you are a developer working with these new features, you must code very defensively. Detect the features are available; check all parts of the feature are still available; use them as a progressive enhancement; and most of all you need to give feedback. The point is to get feedback on the developer and user experiences.

It’s really important to highlight the features can change. This can and does happen. The wake lock API changed significantly during its trial. The way you released the lock was originally pretty weird, devs didn’t like it. So it changed and non-defensive implementations broke.

Origin trials are not standards. WebKit has announced they won’t implement a huge range of features that can be used to fingerprint users’ browsers. So no matter how exciting something may be during origin trial, it doesn’t mean it’s definitely going to become a standard. But if they’re really useful, it gives an effective pathway to petition browsers to implement them.

The web has a lot to offer and it’s getting better. But we need to get it right. We need to avoid the mistakes of the past; and to make sure we get things right for users. But we should experiment with new features! Try them out, see what’s going to be useful, send feedback and help get them released to production.

It’s exciting, this is a conversation between developers and browsers – make use of it!

@philnash