Chrome switches to serial downloading of scripts

810 views Asked by At

Sometimes (not every time, but usually) when I'm developing locally, after hundreds of JS files have successfully been downloaded (looks like we currently pull 1393 scripts), Chrome will switch from downloading the files in parallel to downloading them serially.

The server is node, using express and the module "serve-static". I'm using Chrome 43.0. I'm using node 0.12.2. I'm using serve-static 1.9.3. The files are all being requested using a regular script tag like <script src="foobar.js"></script>. I suspect this is a Chrome issue because the server responses don't change. But the browser requests don't change either, only their timing/ordering.

Any ideas?

enter image description here enter image description here

Edit: Given that this looks to be a Chrome issue, I have submitted a bug-report to Chromium here: https://code.google.com/p/chromium/issues/detail?can=2&q=serial%20script%20downloading&colspec=ID%20Pri%20M%20Week%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified&id=500948&thanks=500948&ts=1434467876

2

There are 2 answers

0
Jan On

This looks to be a Chrome issue, a bug-report has been submitted to Chromium here:

2
Lucas On

Every browser has a maximum number of concurrent requests it will perform at one time from any given host, and will queue all other requests. The majority of browsers support 6 per hostname. See here for more detail on each browser: http://www.browserscope.org/?category=network&v=top

1393 is a lot of scripts to be downloading on a single page. You may need to review the overall project architecture & file structure to minimize those files to address the root.

You can look into minifying/ compressing your javascript files in a single file or set of files, which should be done even if you only have a few javascript files to optimize performance.

You can also use CDN's (Content Delivery Network) to host some or all of the files. By distributing files across different hostnames (ie http://host1.com/file1.js and http://host2.com/file2.js) the browser can download the max concurrent files from each host at the same time.