Difference Between Client-Side & Server-Side Programming

Techwalla may earn compensation through affiliate links in this story.
Web servers make it possible for Web pages to exist.
Image Credit: Ryan McVay/Digital Vision/Getty Images

If you know a little HTML, you can create a functional Web page that informs and entertains site visitors. Basic Web pages can be useful, but it takes programming code to make advanced sites that are interactive, data-driven and more compelling. The type of programming language you use depends on your Web design goals. Before you build a website, learn the differences between client-side and server-side programming. They share some features, but they differ in significant ways.


Client-Side Explained

When you type a URL in your browser's address bar, your computer acts as a client that requests information from a remote Web server. All code, files, data and images that you see on Web pages come from remote servers that send it to browsers. A browser assembles resources it receives and generates the Web page you see. Simple Web pages may only contain HTML statements, text and images, while more complex ones can execute code that resides in the client browser or on the Web server.


Video of the Day

Client-Side Programming Basics

Anyone can create a client-side Web app in minutes by pasting a few JavaScript statements in an HTML document and viewing it in a browser. JavaScript is the main client-side scripting language site owners use in their Web apps. You can use JavaScript to make objects move on a Web page, validate form input, create special effects, show error messages and prompt people for information.


Additional Client-Side Benefits

Because the browser doesn't have to communicate with a remote Web server to perform these types of tasks, client-side code can perform some tasks faster than server-side code. For instance, when you click a button to open a menu, client-side code can run it immediately. If server-side code handled that task, you'd have to wait for the browser to communicate with the server before seeing the menu open. You also don't have to install special software on a Web server to create and test client-side code since all browsers can run client-side code.


Server-Side Programming

Server-side technologies include PHP and Microsoft's ASP.NET. Server-side code runs on a site's Web server instead of in a site visitor's browser. If you visit a Web page that uses server-side programming, you may never know that the server is busy executing instructions while you view the Web page. A good example of server-side processing is an ASP.NET page that allow you to resize an image. After you click a button to upload an image to a Web server, code on the server resizes the image and sends the new image back to your browser.


Additional Server-Side Benefits

Server-side programming also gives you the ability to store and retrieve data. This is important when you wish to perform tasks such as storing and retrieving login information and giving people the ability to look up data stored in a database. That data can reside in locations such as a database or an XML file on your Web server. Server-side processing can also help you keep proprietary code confidential. For example, you could write PHP code that performs calculations using proprietary sales formulas your company keeps secret. Because the code runs on your server, people who view your Web pages in a browser cannot view that code.


Hybrid Web Applications

Many Web apps use a combination of server-side and client-side programming. For example, while client-side scripts can validate form input, it's wise to use server-side code to validate it again after site visitors submit form data to the server. One of your Web pages might use a JavaScript slide show to entertain people and server-side code to process sales orders. Regardless of the technology you use, it's important to test your Web apps thoroughly before deploying them.


references & resources