When JavaScript is busy, a click does not immediately run its handler. The click event waits in the macrotask queue until the current task finishes. section 13.1.1
Two clicks while JavaScript runs
If mainline code runs for 15 ms and two buttons are clicked during that time, both click events wait in the queue. The event loop runs their handlers in turn after the current task completes. section 13.1.1
Figure 13.2. This timing diagram shows how events are added to the task queue as they occur. When a task is done executing, the event loop takes it off the queue, and continues by executing the next task.
Follow the timing diagram to see events enter the queue and tasks run in sequence. section 13.1.1
