0

I have an AngularJS app, which I am looking to optimise for speed.

I am currently uglifying and concatenating all my bower_components which I require into a vendor.js file.

I am currently uglifying and concatenating all my custom js into a scripts.js file.

As such, when a user downloads a page, there are very few resources in the get request. (Presently 6 in total without image assets). The disadvantage is that I have two large-ish js documents to download - about half megabyte in total - The entire doc needs to be downloaded before any page rendering can be done.

My main concern is with the vendor.js file. Is it better to use cdn provided, minified javascript files (approx 10 in total), or is it better to use my concatenated & uglified vendor.js?

The former would mean that the total resources would increase to 16 without image assets, however they would be served by different vendor provided CDN networks, allowing parallel downloading.

Gravy
  • 12,264
  • 26
  • 124
  • 193
  • 1
    As always with this sort of optimisation question, you'll only find out by trying it and profiling the results. Even then, network latencies might make it difficult to get a consistent answer. –  Jun 18 '14 at 10:42
  • possible duplicate of [Should I copy all my JavaScript sources into one single file?](http://stackoverflow.com/questions/8110143/should-i-copy-all-my-javascript-sources-into-one-single-file) – rpax Jun 18 '14 at 11:36

1 Answers1

0

Even though the former would allow parallel downloading, it is 16 different TCP connections with HTTP embedded, so 16 HTTP headers are sent too. TCP is a bit costly to open new connections. So I think it might be better to agglomerate everything in only one file.

What you could do anyway is to test both case and see at the network developer tools of your favourite web browser to see, in average, which is the fastest way. At least doable with Firefox.

Elioty
  • 81
  • 6