Introduction to Client-side
Programming
The World
Wide Web is a consortium of heterogeneous platforms.
When you are developing a web page using you are restricted
to displaying a static page, you can’t take in user input, one can’t introduce
interactivity using HTML.
HTML is basically static, the browser displays the text and
graphics and waits for the user to click a link or fill in a form to return
data to the server. Any dynamic behaviour is limited mainly to clicking a
link or submitting a form to a server and receiving more static HTML.
When you want to introduce interactive features in your web
pages, you can design programs that run either on the server side or the browser
side (i.e. on the users' computer).
Look at today's typical Web-based form. You have designed a
screen that asks users for their names and ages. A visitor to your page types
his name properly, but types in "twenty-four" for his age instead
of the number "24" (Even though the space on the screen is only
three characters wide). This is what happens behind the scenes. When the user
presses the Submit button on the form, his name and his age ("twenty-four")
are sent over his modem across the country to a Web server, where there is
a program a Server-side program) waiting for the input. Your program is expecting
to get good data from the user and is ready to add it to the database. But
instead, it gets this big string of alphabetic characters for the age. So
your Web server creates an HTML page that asks the user to enter a valid age
and sends this page back across the country to the user's browser. The user
will hopefully complete the field correctly the second time and send the data
back to your server again.
This whole process may take just a half a second, or several
seconds, depending on the speed of the user's connection, the speed of the
Net, Web server's load, and so on. This is not what you call a rich user experience--and
what a waste of resources.
This is a typical process that happens millions of times a
day, eats up bandwidth on the net, and uses your Web server CPU time to validate
the input of a user. This validation could easily have been done on his local
PC.
Moving these simple validation tasks from the server to the
client is a simple task and is a big advantage of client-side scripting.
Client-side
scripting is great for animating Web pages and performing local data validation
and computations,
Client side
programming is about extending the functionality of the browser.