Introduction to Web Scripting
Web scripting is the process of creating and embedding scripts in a web-page.
A computer script is a list of commands that are embedded in a program or scripting engine. Scripts
may be written for a variety of purposes such as for automating processes
on a local computer or to generate web-pages on the web.
Types of Script : Scripts are broadly of two types:
1. Client-Side Scripts
2. Server-Side Scripts
Scripting Languages
The programming languages in which scripts are written are
called scripting languages. There many scripting languages
available today and some examples of the most commonly
used are:
1. JavaScript: JavaScript is the most popular client-side
scripting language. It is a high-level, interpreted
programming language that is primarily used to create and
control dynamic content on websites. It is supported by all
major web browsers.
2. VBScript: VBScript is a scripting language developed by
Microsoft , standing for visual basic script. It was primarily
designed to be a lightweight and easy-to-use language for
automating tasks in the Windows operating systems.
However, VBScript has become less common, especially in
web development, as it is only supported by Internet
Explorer and not by other modern web browsers.
3. Hypertext Processor (PHP): PHP is a general-purpose
scripting language that can be used for both client-side and
server-side scripting. It is commonly used for web
development and is embedded in HTML, which makes it a
powerful tool for creating dynamic and interactive websites.
Client-Side Scripting
Client-side scripting is a technique that allows users' devices to run scripts directly in their web browser.
The client-side scripts must first be downloaded on the client's end and then interpreted and executed
by the browser. This type of scripting is browser dependent. That means , the client-side browser must
be scripting enabled in order to run these scripts. Some popular client-side scripting languages are
VBScript , JavaScript , Hypertext Processor (PHP) ,etc.
Uses of Client-Side Scripting
1 User Interaction
Client-side scripting is responsible for making web pages interactive. It allows users to interact
with elements on a page, such as buttons, forms, and menus.
2 Dynamic Content
Scripts can be used to dynamically update web page content without reloading the page. This
can be used to display information that changes frequently, such as stock prices or weather
updates.
3 Web Applications
Client-side scripting is essential for building web applications. These applications can be used for
tasks such as online shopping, email, and social networking.
4 Multimedia
Scripts can be used to control multimedia elements on a web page, such as videos and audio
files.
Differences with server-side scripting
Client Side Scripting Server side scripting
1. Script code is downloaded and executed at 1. Script is executed at the server-end and the
client end. result is send to the client-end.
2. Generally faster for user interactions because 2. Can be slower for user interactions because
the code runs directly on the user's machine each request may require a round trip to the
without needing to communicate with the server. However, server-side scripts are
server. However, performance can vary based typically more powerful and capable of
on the user's device and browser capabilities. handling complex tasks.
3. Services are secure as they do not have 3. Services can directly interact with databases,
access to files and databases. It must make retrieve and manipulate data, and send the
requests to a server-side script to access the processed information back to the client.
database. 4. Browser-independent as it runs on the server.
4. The code's behavior can vary depending on The client only receives the final output in a
the user's browser and its version, leading to standard format (like HTML), supported
potential compatibility issues across all browsers.
Advantages of Client-Side Scripting
1. Improved User Experience: Client-side scripting enables interactive features, such as dropdown
menus, sliders, drag-and-drop elements, and real-time form validation, making the user experience
more engaging.
2. Reduced Server Load: By shifting some of the processing tasks to the client’s browser, client-side
scripting reduces the load on the web server. This can lead to better scalability and improved server
performance.
3. Faster Performance: As scripts run in the user's browser, there’s no need for a round trip to the server
for certain tasks, leading to faster execution and a more responsive interface.
4. Customization and Personalization: Client-side scripting can be used to tailor the content or
interface based on user preferences or behavior. For example, JavaScript can save user settings in
cookies or local storage and apply them on subsequent visits.
5. Security: By handling more operations on the client side, some server-side logic can be concealed,
reducing the risk of exposing sensitive server-side code.