Timers

Here, we are going to learn about optimizing JavaScript timers in detail.

What are timers and how do they affect performance?

Timers are built-in functions of JavaScript that allow the execution of either inline JavaScript code or permit functions to be called at a specific point of time after, or repeatedly during, the life cycle of a JavaScript application.

Timers are a great tool in a JavaScript developer's toolbelt, but they have their own issues when it comes to performance. Consider the fact that the JavaScript language is single-threaded, which means that every line of code in our application cannot be fired at the exact same time as another piece of code in our application. To get around this, we use a built-in function called setTimeout ...

Get Mastering JavaScript High Performance now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.