7 ms·
Great question, and one i am not totally sure of myself. I guess the question is: if an event doesn't have any handlers listening for it, does it get queued and
by philip_roberts 12y ago
Great question, and one i am not totally sure of myself. I guess the question is: if an event doesn't have any handlers listening for it, does it get queued and processed regardless? This is something I've often wondered about myself but never properly tested/been sure about.
My _guess_ would be yes, this would work. Regardless of how fast the file loaded. One way to test it would be to stick a large while loop between readastext and addeventlistener to block the stack for a few seconds and guarantee that the file is read before the handler is bound.
I'll try and take a look when I am back at a computer if nobody else responds either way :)
- philip_roberts 12y agoI'll add, most of my understanding was done this way: somewhat experimentally. Come up with a hypothesis of how things might work, figure out a way to prove it, and see if I was right.
- jarek-foksa 12y agoThanks for response! You are right, I have just done some tests with a time-expensive "for" loop placed right before the addEventListener() call and the callback appears to be fired after the stack is cleared / the main function returns.