DEV Community

Adam Roynon
Adam Roynon

Posted on

Client-Side vs. Server-Side Programming

Client-side code runs on a client's computer whereas server-side code runs on a web server before a webpage is sent to the client. A user first requests a webpage from a server, the server may then run some operations or processes, then afterward the webpage is sent to the user.

JavaScript is a well-known client-side scripting language, this means it runs and is executed on the client's computer. Imagine a webpage has a button and when you click it a message appears. This can be achieved using JavaScript, and it will be executed on your machine without having to send any request to the server. Using client-side code can reduce the amount of work the server has to do, freeing it up for more important tasks.

PHP is a well-known server-side programming language, which means it is executed on the server-side prior to the user receiving the webpage. Whatever code is written in PHP will not be visible to the user, on the client-side, as the code will have already been executed and removed before the webpage is sent to the user. This can allow for more private code, such as encryption algorithms, to be written in PHP and not be accessed, read, or reverse-engineered by the user.

Using a server-side programming language can also allow more complex operations involving the server. For example, using a client-side language such as JavaScript you cannot access a database directly or write/read files that live on the server. Using a server-side programming language such as PHP you can save information to a database and manipulate files on the server, such as allowing a user to upload a file to the server. Saving information on the server-side can also allow multiple users to see the same information on different computers. Imagine a high scoreboard, you would want every user to see the same high scores list and this could only be achieved by saving the information to a server.

This post was originally published on https://acroynon.com

Top comments (1)

Collapse
 
eddystark profile image
Eddy Stark

Great read!