Welcome to WebmasterWorld Guest from

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

Is client-side scripting essential?

7:18 am on Apr 5, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Aug 17, 2007
votes: 0


As far as I know there are certain things that javascript(client-side script) cannot do but php(server-side script)can. For example - processing of the input variables from forms.

And there are few things which can be done by using either of the two,that is, they can be done in javascript as well as in php. So in this case, if we don't need to hide the code from users, we can use javascript. But would it be ideal to do so?

Is it true that use of php puts additional load on the server which can otherwise be avoided by using javascript?

My overall question is :

What do you think should be the ratio of javascript code and php code for problems which can be coded in either ways? How do we decide if we are going to code a certain problem (which obviously comprises just a small part of any project) in javascript or php?

6:40 pm on Apr 5, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

I approach the problem like this.

Client-side scripting can be enabled or may not be present in the browser (for example, search engine spiders.) For this reason, anything you do in Javascript must be duplicated or emulated by your server side programming or it is doomed to sporadic failure.

Example: shopping cart that calculates totals directly on the page using Javascript. If JS is disabled, when submitted you get an order for $300 of items but the total . . says $0. And that is the value that is passed to the payment processor. So your server-side programming - php, perl, asp, whatever - needs to replicate exactly what your Javascript does to insure proper calculations.

This, I think, invalidates and answers the question about "we can do the same thing with one or the other".

So to answer the question, Javascript or other client side processing is only essential in the sense that we use it to enhance the visitor's experience on our sites; to perform many of the tasks and speed up the processing of their quest without making an round trip top the server each time. Anything that relies on Javascript to function properly will eventually fail when a user agent comes along in which it's disabled.

12:48 pm on Apr 6, 2008 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
votes: 1

For almost all problems I decided to solve them in server side scripting because it is easier to maintain and test for me than a client side script would be. And not all browsers accept JavaScript and not all browsers may give exact the same expected result.

Another reason to go for server side scripting is that it poses no problem with search engines. JavaScript is effectively thrown away by search engines (although I have seen some instances in my logfile where Googlebot fetched my .js files so they might parse it in some way) The result of a server side script is plain (X)HTML which is easily interpreted by all search engines.

9:47 pm on Apr 16, 2008 (gmt 0)

Full Member

5+ Year Member

joined:Mar 22, 2008
posts: 315
votes: 0

Definitly go server-side when you can. JavaScript should only be used to add "snazz" to the site, but as previously mentioned, it should not be relied on for site functionality.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members