title: Does JavaScript spawn threads for non-blocking AJAX?
body: <p>The general perception is that JavaScript is intrinsically single-threaded but it can run asynchronously. I wonder how a single-threaded model like this handles AJAX requests that are non-blocking?</p>
  
  <p>Lets say a non-blocking AJAX request is fired in a browser, but doesn't get a response immediately. If the event loop keeps checking for the response, doesn't the execution get blocked? Does the event loop keeps checking for its status and 're-adding' the task to the back of the macrotask queue when there is no response? </p>
  
  <p>From what I understand, Node.js does silently spawn threads to handle I/O operations accessing disks, databases, network sockets etc. Does JavaScript in browsers spawn threads to handle AJAX too?</p>
  
  <p>A similar question could be asked about the following:</p>
  
  <pre><code>var img = new Image();
  img.onerror=function(){alert('error: '+this.src);}
  img.onload=function(){alert('image loaded: '+this.src);}
  img.src='path/to/image.jpg';
  </code></pre>
  
  <p>Does the last line of code above causes an additional thread to be spawned, because the statement seems to be non-blocking?</p>