Search code examples
javascriptajaxbrowserxmlhttprequest

Do browser block JS execution on several simultaneous async XMLHttpRequest?


I've heard that browsers issue only limited number of simultaneous requests (like 2 or 6).

If I issue several XMLHttpRequest.send() do my JS code blocked at some point (for example on send call)?

Or all requests collected in browser queue and only portion of them will be sent to network?


Solution

  • Correct, a browser will only send a certain number of requests in parallel. Your code however won't block unless you send synchronous xhr requests (which you most likely don't do).

    When the max. parallel request limit is reached the browser will queue the other requests and process them as soon as another running requests has finished. But this mechanism does not affect your code. Only difference is that request durations (duration = time the requests completes - time issueing the request in JS) increase.