Welcome Guest Search | Active Topics | Sign In | Register

Ability to combine all Javascripts into a single file Options
Brenden
Posted: Wednesday, March 25, 2009 11:37:10 AM
Rank: Newbie
Groups: Member

Joined: 3/3/2009
Posts: 4
Hello.

Following the guidance in the documentation, I've deployed with static script files. Still, there are about 14 separate javascript requests that I would like to consolidate into a single call. It would be very beneficial from a performance standpoint to have a single Javascript file versus 14 separate files.

Thanks.
eo_support
Posted: Wednesday, March 25, 2009 11:53:06 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,200
Hi,

Merging all files into a single file is not a good option from performance standpoint of view. The reason is a single control only uses some of it and never all of it. The 14 files include JavaScript code for all of our controls. So if the are merged into a single file, the contents of all the 14 files will always be transferred to the client side; On the other hand, with the current solution, only the files are needed are being transferred to the client side.

Thanks!
Brenden
Posted: Wednesday, March 25, 2009 12:04:25 PM
Rank: Newbie
Groups: Member

Joined: 3/3/2009
Posts: 4
Right, I understand that. Unfortunately, we have two issues:

1. We're only using the grid and calendar components, but the control is making 14 requests.
2. Assuming that we have a page that uses all 14 Javascripts (which we may have), it is far better to have a single HTTP request versus 14 from a performance standpoint. I've yet to receive a valid reason why the javascript files can't be combined into a single file.

eo_support
Posted: Wednesday, March 25, 2009 12:28:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,200
Hi,

The most important reason that we can not combine them is some JavaScript files are shared by multiple controls. If you have two controls: Control A and Control B, where A use X and Y and B use X and Z. Then there are three options:

1. Divide them as X, Y, Z as it is now, so
a. if user only uses A, they download X and Y;
b. if user only uses B, they download X and Z;
c. if they use both, they download X, Y and Z;

2. Combine JavaScript used by each control into a single file. So there will be two JavaScript files, XY and XZ.
a. If user uses A, they download XY;
b. If user uses B, they download XZ;
c. If user uses both, they download XY and XZ;

3. Combine JavaScrit used by all controls into a single file. So there will be one JavaScript file, XYZ.
a. If user uses A, they download XYZ;
b. If user uses B, they download XYZ;
c. If user uses A and B, they download XYZ;

Option 1 takes the least bandwidth for all cases. Option 2 has similar result with option 1, except for:
i. It uses fewer requests for 2.a and 2.b;
ii. It downloaded the contents of the original X file twice for case 2.c;

Where as option in option 3:
i. It uses fewer requests for 3.a and 3.b;
ii. It downloaded more contents than needed for both case a and b;

So each option has its advantages and disadvantages. In reality the number of request matters much less than the size needs to be downloaded because of HTTP Keep Live option. Every picture you use in the page is an additional request, so if that is a problem, then nobody would use any pictures. The same goes for css files or any other external files your webpage references. Both browsers and servers are well optimized to handle multiple requests. The browser actually keeps the connection open between multiple requests. So there isn't much more overhead at all. On the other hand, downloading code that it does not need is a real waste.

Another matter to consider is that all JavaScript files are cached by the browser by default. So if user has hit case 1.a and then 1.b, for case 1.b there will only be one request because the browser no longer need to download X again.

Hope this explains the issue better.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.