15 Web APIs you've never heard of

11. Generic Sensor API

There are already a lot of Web APIs that define interfaces for different kinds of sensors (for example, the Device Orientation API and the Geolocation API). Unfortunately those APIs do not have a common interface and are all used differently – for example, by providing callback handlers in one case, or by registering event handlers in another. The goal of the Generic Sensor API is to define a set of common, generic interfaces for accessing any kind of sensor. Concrete sensor APIs that are based on the Generic Sensor API (such as the Ambient Light API) extend generic interfaces and add functionality as required.

12. Accessibility API

Accessibility is an important point when developing web applications. There are already standards like ARIA, which provides an ontology of roles, states and properties to define accessible user interfaces on the web. It can also enrich HTML elements (on a markup level) with information that can be used by assistive technologies like screen readers. 

However, the Accessibility API creates a standard Web API for JavaScript, based on ideas from ARIA and other existing accessibility APIs like Web Accessibility and Actions by Microsoft, the Web Accessibility API by Mozilla or other native platform APIs (including the Java Accessibility API). 

Using the new property a11ement on DOM elements, developers can access semantic information about the element like the role, the state, relation to other elements and many more, using JavaScript.

13. Font Loading API

With the Font Loading API you can load font faces dynamically with JavaScript

With the Font Loading API you can load font faces dynamically with JavaScript

When you are using custom fonts on a webpage, downloading the font files can take time, depending on the bandwidth and the size of the font files. This can then lead to display problems, such as flickering content when the webpage starts rendering without the font face being loaded first. 

The new Font Loading API addresses this problem and it can define a standardised API for downloading font faces by utilising JavaScript. Developers can choose when to load a font face and what to do when it has been downloaded.

14. Web Bluetooth API

The Bluetooth protocol is a standard that is often used in the field of IoT, for example to connect a smartphone or tablet to other devices like health trackers to read certain sensor values. For mobile web applications it is already possible to connect via Bluetooth by using PhoneGap and its plugins, but if you want to use Bluetooth inside a web application on a desktop computer or laptop then you will still need to install an extra browser plugin. 

The goal of the Web Bluetooth API that is being worked on by the W3C Web Bluetooth Community Group is to provide a standardised API for accessing Bluetooth devices through the browser, without the need for any plugins. 

15. Visual Viewport API

The Visual Viewport API solves those layout viewport vs visual layout clashes

The Visual Viewport API solves those layout viewport vs visual layout clashes

As you know, web applications contain two viewports: the layout viewport, which represents the space where a page lays out its elements into, and the visual layout, which represents what is visible on the screen. However, working with those two layouts can be a confusing task: while some properties like innerWidth and innerHeight are relative to the visual viewport, other properties such as those for accessing event coordinates are relative to the layout viewport. 

On top of that, the browser behaviour can also differ when you pinch-zoom into an application (an online demo that visualises those problems and the relationship between these two different layouts in general can be found here). 

To overcome these problems and disparities, the goal of the Visual Viewport API is to add new properties that are all related to the visual viewport, as well as to introduce a property visualViewport on the window object.

This article originally appeared in net magazine issue 292; buy it here!

Related articles:

Thank you for reading 5 articles this month* Join now for unlimited access

Enjoy your first month for just £1 / $1 / €1

*Read 5 free articles per month without a subscription

Join now for unlimited access

Try first month for just £1 / $1 / €1

Philip is a software engineer working at the Fraunhofer Institute. He has written three books and many articles on Java and JavaScript, and is the creator of Philip’s JS Recipes.