Browser "Events"

  • Only one line of JavaScript can run at a time...
  • ... but the browser can keep track of multiple events at the same time
  • The browser can keep track of multiple timers, network requests, user interactions, etc
  • This is why the browser "catches up" after lagging
  • Timers, interactions, etc can cause your code to be put on a queue
  • If nothing else is happening, your code runs immediately
  • If other stuff is happening, the event will be added to the end of the line
  • When the browser is idle, it will run things from the front of the queue

14 / 27