Do event handlers go on the JS Message Queue, or just events?

217 Views Asked by At

So I was recently directed to this very good article by a coworker:

http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/

In it, they explain how when a Javascript event is triggered, it goes onto a message queue and is later dequeued and the handler for that event is executed. This got me to thinking: how does this perform in the case where there are multiple handlers across containing elements for a single event?

Does the event go into the message queue when triggered and, upon being popped off, execute its capture/bubble routine and fire all relevant handlers? Or when the event is triggered, is the capture/bubble routine done then to determine which handlers to be inserted into the queue as messages? Does it vary between browser implementations?

I devised a test to try to get to the bottom of it based on a performance comparison, but am not sure it's of much use: http://jsperf.com/testing-bubbling

Does anyone know whether events, handlers, or some combination of both are pushed into the message queue, and where the capture/bubble phases of JS events come into all of this?

Thanks in advance for your time!

0

There are 0 best solutions below