387429 (2) [Avatar] Offline
I have a question on event queue, which is covered in Chapters 2 and 13: Suppose I have the following code:
var url = ...; // whatever url
var xhr = new XMLHttpRequest();
xhr.open('get', url, async);

// line 6: Code that will take a long time ...

function callback() { 
  // ... 
xhr.addEventListener('load', callback);
xhr.addEventListener('error', callback);

If the code on line 6 will be done after the xhr request is done, will xhr's "load" and "error" events still be put into the event queue? Or these two events won't get into the queue at all because they don't have any event handlers attached to them (yet)?

Thank you very much for your help!
Inner-self (8) [Avatar] Offline
Hello User#387429

Which book are you reading? My search for xhr yielded no results.

thank you.
387429 (2) [Avatar] Offline
The code was not from the book. I was trying to understand how the event queue really works. Thank you for your reply.