We help IT Professionals succeed at work.

Client-side JavaScript vs. Server-side Java - Performance

Medium Priority
541 Views
Last Modified: 2012-05-06
I would like to add up the values in rows coming back from a database in a result set so that I get subtotals and totals in a JSP using Javascript.  Say there were 200 hundred rows with 3 columns needing subtotals and totals, would performance be faster on the client using Javascirpt or would it be faster and more efficient to sum up the values on the server, like Websphere for instance?
Comment
Watch Question

Commented:
Hi,

Server side rendering of the data will always be faster.  Firstly, the server will more than surely be superior in power, and the engine used on the server will have a far faster throughput than javascript.

Secondly, if you were to use client side scripting to render the data, you are reliant on a number of things, namely that the pc the browser is on is fast enough to render the data without it taking too long, and that the client's browser actually has javascript enabled!  This is especially important if you want to take accessibility into account, as the browser being used might not be sophisticated enough to render javascript.

hth

-null-

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Most Valuable Expert 2011
Author of the Year 2014
Commented:
Clients can turn off Javascript.  Also, if you want to do Javascript calculations, you must first send the data to the browser.  Depending on the amount of data you must send, this can be a bit time-consuming.  I would go the server route, too.

Best, ~Ray

Author

Commented:
Thanks to both of you experts!  I will take your counsel.  I have always heard since the beginning of the Web era, do it on the server!

Author

Commented:
Very good help!  I'm glad there are folks like you on EE!
Most Valuable Expert 2011
Author of the Year 2014

Commented:
Thanks for the points and for your kind words! ~Ray
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.