homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

Is client-side scripting essential?

5+ Year Member

Msg#: 3619731 posted 7:18 am on Apr 5, 2008 (gmt 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?



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

Msg#: 3619731 posted 6:40 pm on Apr 5, 2008 (gmt 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.


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

Msg#: 3619731 posted 12:48 pm on Apr 6, 2008 (gmt 0)

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.


5+ Year Member

Msg#: 3619731 posted 9:47 pm on Apr 16, 2008 (gmt 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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved