Chapter 21. Upcoming APIs

With the flurry of interest that Ajax brought back to web development also came a call to restart the browser evolution. As part of this movement, a number of new APIs began to take shape. Some were based on things that browsers had already implemented, some on ideas of how to fix things that were broken, and some were born out of developer demand. The result was a number of specifications describing ways to extend JavaScript in the browser so that it becomes more compatible with how developers are using it.


The APIs covered in this chapter are, at the time of this writing, still under development and may change significantly before being finalized. These changes may include renaming, addition, and removal of methods and/or properties. The following is intended solely to indicate the direction that JavaScript is going.

The Selectors API

One of the most popular capabilities of JavaScript libraries is the ability to retrieve a number of DOM elements matching a pattern specified using CSS selectors. Indeed, the library jQuery ( is built completely around the CSS selector queries of a DOM document in order to retrieve references to elements instead of using getElementById() and getElementsByTagName().

The Selectors API ( was started by the W3C to specify native support for CSS queries in browsers. All JavaScript libraries implementing this feature had to do so by writing a rudimentary CSS parser and then use existing ...

Get Professional, JavaScript® for Web Developers, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.