Chapter 25

Emerging APIs

WHAT’S IN THIS CHAPTER?

  • Creating smooth animations
  • Working with files
  • Background JavaScript with Web Workers

The introduction of HTML5 also spurred a tremendous growth in JavaScript APIs aimed at the future of web applications. These APIs are not part of the HTML5 specification but rather exist in their own specifications that are often bundled “HTML5 Related APIs”. All of the APIs in this chapter are still undergoing a fair amount of work and are not fully stable.

Despite that, browsers have already begun implementing the various APIs, and web application developers have begun using them. You’ll note that many of these APIs have browser-specific prefixes in front of them, such as “ms” for Microsoft or “webkit” for Chrome and Safari. These prefixes allow browsers to experiment with new APIs while they are still in development, knowing that the final, nonprefixed version will be consistent with other browsers.

requestAnimationFrame()

For a long time, timers and intervals have been the state of the art for JavaScript-based animations. While CSS transitions and animations make some animations easy for web developers, little has changed in the world of JavaScript-based animation over the years. Firefox 4 was the first browser to include a new API for JavaScript animations called mozRequestAnimationFrame(). This method indicates to the browser that an animation is taking place so that the browser may, in turn, determine the best way to schedule a redraw. ...

Get Professional: JavaScript® for Web Developers, Third 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.