Call (877) SITE-OPT (748-3678)

Code: The Two-connection limit

Chapter 8 - Ajax Optimization

The reality of the two-connection limit is the primary reason why people host images or other dependent objects such as JavaScript and CSS files on other domains. For example, the site serving an HTML page containing the following image references:

<img src="image1.gif" />
<img src="image2.gif" />
<img src="image3.gif" />
<img src="image4.gif" />

would find that using other fully qualified domain names such as those shown here will increase the fetching browser’s connection efficiency:

<img src="" />
<img src="" />
<img src="" />
<img src="" />

Your Ajax programs can make only two connections at a time, so if you make a third or fourth request, it will have to wait until one of the other requests finishes. Now, this can be quite problematic if your requests stall for some reason. You will find that your connection will then choke.

Given the previous discussion of utilizing additional domains to increase image request parallelization, you might be tempted to use the same trick here, but it will not work. You see, Ajax falls under the security policy known as the Same-Origin Policy (Same origin policy Wikipedia), which limits you to making requests from the same domain name that served the page. So to minimize the impact of HTTP request bundle your scripts together and group requests.


We have done extensive testing on this default.
There are ways to modify it in the browser, but by default, two is the limit of simultaneous connections, at least for JavaScript files. See for more details.
Copyright © 2002-2018 Website Optimization, LLC. All Rights Reserved - Free website speed test - Privacy Policy
Last modified: February 19, 2009.

Follow us on: Twitter, Google+, Facebook, Linked In