Browser queue wait time

There can be multiple reasons for a request to wait in the browser queue before it is sent to the server. The two most common reasons are:


    • If there are multiple JavaScript files on a web page, they are loaded one after the other by the browser and not loaded simultaneously. They are loaded in the same sequence as they are present on the web page. A web developer should always consider if it is possible to convert multiple JavaScript files on a page into a single JavaScript file.


      • Each browser has a limit on the number of concurrent requests that can be made to a single domain by a web page. For example, this limit is six for Firefox 3. If there are eight images on a web page that have to be loaded from the same domain, six requests will be made simultaneously, and the request for two images has to wait before a response for any of the previous two requests is received from the server.

 


When optimizing the performance of a web application from the browser's perspective, browser queue wait time is a very important consideration.


So how to bypass the maximum concurrent requests limit by the browser ?


If, for whatever reason, a web page needs to make a lot of requests to the server to get images, CSS files, AJAX responses, and so on, then one common technique is to host the image files on a separate subdomain. For example, host all the images for the Packt site on images.packtpub.com instead of the www.packtpub.com subdomain. However, it is important to keep in mind that every subdomain that is added also requires a DNS lookup. Based on a study by Yahoo, having two to four subdomains for a site is a good compromise between parallel requests and DNS lookups.

你可能感兴趣的:(JavaScript,Web,Ajax,css,firefox)