You are previewing Secrets of the JavaScript Ninja.

Secrets of the JavaScript Ninja

Cover of Secrets of the JavaScript Ninja by John Resig and Bear Bibeault Published by Manning Publications
O'Reilly logo

Chapter 8. Taming threads and timers

This chapter covers

  • How JavaScript handles threading
  • An examination of timer execution
  • Processing large tasks using timers
  • Managing animations with timers
  • Better testing with timers

Timers are an often misused and poorly understood feature available to us in JavaScript, but they can provide great benefit to the developer in complex applications when used properly.

Note that we referred to timers as a feature that’s available in JavaScript, but we didn’t call them a feature of JavaScript itself—they’re not. Rather, timers are provided as part of the objects and methods that the web browser makes available. This means that if we choose to use JavaScript in a non-browser environment, it’s very likely ...

The best content for your career. Discover unlimited learning on demand for around $1/day.