Question

Has any analysis been done on modern browsers to determine if script concatenation is still beneficial? It seems chrome can load many scripts in parallel so as long as the AMD dependency chain is shallow (or all dependencies are required up front) concatenation might not speed up the loading process. I'm looking for actual data but thoughts are welcome.

To me it seems concatenation might slow the process since multiple scripts can now compile in parallel.

Was it helpful?

Solution

Short Answer:

Yes.

Longer Answer:

Each additionally requested file adds (so called overhead):

  • A DNS Lookup - if the DN is not already cached
  • A TCP Handshake
  • A HTTP Request itself

and only then the real download of the file begins.

So by concatinating you could save these factors - which would add up on many files.

Just today I watched an interesting talk by Paul Irish exactly about this, I recommend you watch it: "Delivering the goods"

To quote one of his slides:

Most of the HTTP data flows consist of small, bursty data transfers, whereas TCP is optimized for long-lived connections and bulk data transfers. Network roundtrip time is the limiting factor in TCP throughput and performance in most cases.

Consequently, latency is the performance bottleneck for HTTP and most of the web.


Also you have to consider, that not every browser loads as many files in parallel like chrome. I found an SO-Post about how many connections the browser does in parallel (from 2013).

OTHER TIPS

Of course it is beneficial. Each separate javascript file is a request to the server. And that takes time because of the added overhead.

The less javascript files you have, the less time it will take to get them all from the server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top