---
title: "Client-side versus server-side scripting"
subject: "Web Technology"
chapter: 3
key: "semester_7/web_technology:client-vs-server-side-scripting"
source: https://www.bctengineer.com/q/semester_7/web_technology/client-vs-server-side-scripting
site: BCT Engineering
---

# Client-side versus server-side scripting

Web Technology · Chapter 3: Server-side programming

- Asked in: 2076 Chaitra, 5 marks; 2074 Asoj, 7 marks; 2074 Chaitra, 4 marks (asked 3 times)
- Video: [Client Side vs Server Side Programming - Basic Concepts](https://www.youtube.com/watch?v=1SwWo0wHx6Q) — Stefan Mischook
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/web_technology/client-vs-server-side-scripting
- Whole chapter: https://www.bctengineer.com/md/semester_7/web_technology/chapter-3

## Question

What is the difference between client-side scripting and server-side scripting? Explain with example.

## Short answer

Client-side scripting runs in the browser using JavaScript for validation and UI updates, while server-side scripting runs on the server using PHP or Java for database work and authentication. Server-side code is hidden and more secure but needs a round trip.

## Answer

**Client-side scripting** means scripts that are downloaded with the page and run in the user's browser (e.g. JavaScript). **Server-side scripting** means scripts that run on the web server, which generates the HTML sent to the browser (e.g. PHP, JSP/Servlets, ASP.NET, Node.js).

| Basis | Client-side scripting | Server-side scripting |
|---|---|---|
| Execution | In the browser | On the web server |
| Languages | JavaScript, VBScript | PHP, Java (JSP/Servlet), Python, ASP.NET, Node.js |
| Source code | Visible to the user (View Source) | Hidden; the user sees only the output HTML |
| Server load | Low; uses the client's CPU | Higher; the server does the work |
| Response speed | Fast for UI actions, no round trip | Needs a request-response trip |
| Database access | Cannot access it directly | Can connect to databases and files |
| Security | Less secure; user can modify code | More secure; code and data stay on the server |
| Dependence | Depends on browser support/settings | Independent of the browser |
| Typical uses | Form validation, animation, DOM changes, AJAX | Authentication, database operations, sessions, dynamic pages |

#### Example
Client-side (validates before sending):
```html
<script>
function check(){
  if(document.getElementById("age").value < 18){ alert("Must be 18+"); return false; }
}
</script>
```
Server-side (PHP creates the page and reads the database):
```php
<?php
$name = $_POST['name'];
echo "Welcome, " . htmlspecialchars($name);
?>
```
In practice both are used together: JavaScript gives quick feedback, and PHP re-validates and stores the data.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Where does client-side scripting run?
   A. On the web server
   B. In the database
   C. In the user's browser
   D. In the DNS server
   Answer: C. JavaScript is downloaded with the page and runs in the browser. (Key point: Execution location)

2. Which source code can the user see with View Source?
   A. Server-side script code
   B. Both are hidden
   C. PHP code
   D. Client-side script code
   Answer: D. Server-side code stays on the server; the user sees only output HTML. (Key point: Source visibility)

3. Which can connect to databases directly?
   A. Server-side scripting
   B. Client-side scripting
   C. Neither
   D. Only CSS
   Answer: A. Client-side scripts cannot access them directly. (Key point: Database access)

4. Why use both in practice?
   A. Server-side makes client-side unnecessary
   B. JavaScript gives quick feedback; PHP re-validates and stores the data
   C. Client-side is more secure
   D. They cannot be combined
   Answer: B. Client-side validation can be bypassed, so the server re-validates. (Key point: Using both)

## Related in Web Technology

- [Server side languages and multi-tier architecture](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Aserver-side-languages-multitier) — Web Technology, chapter 3
- [Internet vs WWW; client-server paradigm](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Ainternet-vs-www-client-server) — Web Technology, chapter 1
- [Server-side programming and Java Servlet](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Aserver-side-programming-servlet) — Web Technology, chapter 3
- [Short note: Server side programming](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Ashort-note-server-side-programming) — Web Technology, chapter 3

## Related in other subjects

- [Client-server versus distributed object architecture](https://www.bctengineer.com/question.md?key=semester_5%2Fsoftware_engineering%3Aclient-server-vs-distributed-object) — Software Engineering, chapter 3
- [Multiprocessor versus client-server architecture](https://www.bctengineer.com/question.md?key=semester_5%2Fsoftware_engineering%3Amultiprocessor-vs-client-server) — Software Engineering, chapter 3
- [Server before client; TCP reliability](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Atcp-server-before-client-reliability) — Computer Networks and Security, chapter 5, asked 2×
- [Short note: Client-Server and Master-Slave](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Ashort-note-client-server-master-slave) — Big Data Technologies, chapter 1
