Svbtle

 

Svbtle

Chrome’s requestAutocomplete()

Another Google I/O, and another raft of awesome products. One announced API that I’m particularly excited about is requestAutocomplete(), a feature which is landing in Chrome Canary for Windows and Mobile (with OSX support coming shortly). What this API does, in a nutshell, is give you programatic access to autocomplete (or autofill) data.

Autocomplete was originally designed to make it quicker to fill out forms, but what if we could remove the forms altogether! Back in June I proposed just such an API - a way to programmatically retrieve autofill data stored in the browser. The proposal has evolved, improved, and is now going to be baked into future versions of Chrome.

1Zh85u4gzhhDkC6myiRAyO2SH1iRgCCbUoJ4O.png

What does it look like? Essentially it involves calling requestAutocomplete() on a form element. The form doesn’t necessarily need to be shown to the user, but the browser uses it to detect which input types to autocomplete.

<button id="checkout">Checkout</button>  

<form id="payment" hidden>
  <input autocomplete="cc-name" name="myname">
  <input autocomplete="cc-number" name="ccnumber">
  <input autocomplete="cc-exp" name="ccexp">
</form>

<script>
  (function(){
    var form = document.getElementById('payment');
    var button = document.getElementById('checkout');

    if (!("requestAutocomplete" in form)) return;

    button.addEventListener('click', function(){
      form.requestAutocomplete();
    });

    form.addEventListener('autocomplete', function(){
      // The form contains the data. We could either submit it, or read the data
      form.submit();
    });
  }).call(this);
</script>

Once requestAutocomplete() has been called, a permissions info dialog will be displayed by Chrome, prompting the user to share their information with the page.

What does this mean in practice? It means that we can replace most forms with two-click signups and two-click payments, dramatically improving usability and conversion rates.

The fact that most people already have autofill data already in Chrome, and that Chrome is an evergreen browser automatically updating itself, should mean adoption of this API will be swift. Once businesses see improved conversion rate data (something we’re working on demonstrating), then integrating with this API should be a no brainer. My hope is that other browser vendors will follow suit and also implement support.

You can find the preliminary API docs on chromium.org.

 
2,516
Kudos
 
2,516
Kudos