views:

364

answers:

3

Which processing is fast Client-side or Server-side? for client side processing browser need to download every JavaScript first and in server side programming everything happens on server without downloading anything to user PC?

if for a particular functionality we have solution in both javascript and php/asp then what should be chosen and why?

+2  A: 

Downloading the JavaScript upfront is usually quicker as a server round trip isn't required (and it is networking operations that are usually the most time consuming).

That said, there should always be a server side solution for any essential functionality (as JS support is not guaranteed), and performance shouldn't be the first thing you think about (trust should be, e.g. you can't trust client side code to make certain that data isn't going to trash your database).

David Dorward
u r right but for even if javascript is enabled by user which would be the best in performance? would server-side be quicker always? which will be good for mobile users ?
metal-gear-solid
See the first paragraph of my answer. Obviously not, reread said first paragraph. Mobile devices may or may not have JS support (which may or may not be turned on).
David Dorward
+1  A: 

There are several factors, and several trade-offs, to consider here.

The server machine is usually stronger than the client machine. OTOH, there are usually far more clients than servers. Thus, when #clients exceeds a certain threshold, client-side processing is faster (the server will have to process computations from all clients which will outweigh its stronger processor).

But, if the processing is bounded mainly by network bandwidth, that is: most processing time is spent on downloading stuff, and the downloaded material is relatively stable, then it will be faster to download once into the server and do the processing there.

Finally, if the results of the computations do not change from one client to another, then - again - it makes more sense to compute it, once-and-for-all, at the server.

Itay
A: 

I'm a big fan to move all possible processes on the browser.If you target JS enabled browsers(ie: for a web app)

Mainly to offload the server of the rendering process and save some network bandwith.

Rendering HTML client side is really fast today, even on web enabled mobile phones, why not use this computer power available in the browser?

And once the HTML's, CSS and JS are in the browser cache (in the current session or a previous one) only the data is traveling the network.
And if you put all those static files on a CDN, imagine the gain in speed.

These options in my experience gives a much more responsive experience to the user.

We are kind of mad about speed and it was the design we took to build our web app:

  • static files on a CDN
  • a backend to serve only JSON services and handle security
  • and we use PURE to render the JSON in HTML client side
Mic