Scripting

Scripting allows you to add enhanced functionality and interactivity to your website.

Examples

How Scripting fits into Website Development

HTML provides the structure of a web page and CSS provides the styles. Scripting takes it further and can provide extra functionality and interactivity.

You can use scripting to do things like open dialog boxes, access a database, create login pages, display personalized web pages, and much more.

Some of the more popular scripting languages on the web include JavaScript, PHP, ColdFusion, and Python.

Client-Side Scripts

Client-side scripts run in the browser. This means that the script is downloaded with the HTML file (or as a separate file) and runs in the user's browser. This enables the script to run without further requests to the server.

Client-side scripts can do things like launch popup messages, set cookies and "remember" the visitor, check which browser is being used, and more. The most popular client-side scripting language (by far) is JavaScript. In fact, it is the default scripting language for HTML5. You can add scripts to an HTML page using the script tag.

Server-Side Scripts

Server-side scripts run on the website's server. The script remains on the server and is not downloaded with the HTML.

This means that a request to the server is required any time a server-side script needs to run.

But because they run on the server, server-side scripts can do things that client-side scripts can't.

For example, server-side scripts can access databases, provide access control, provide personalization, send mail, and much more. This enables you to build complex web applications such as shopping cart sites, social media platforms, web mail, forums, photo gallery sites, etc.

To run a server-side script, you first need to ensure the environment is set up to support the scripts. Usually, this involves installing the scripting environment on the server. For example, to run ColdFusion scripts you first need to install the ColdFusion application server and connect it to your web server. Likewise, to run PHP scripts you need to install PHP and connect it to your web server. Doing this is usually quite straightforward.

Most web hosting companies include server-side scripting in their plans. Most web hosts include PHP in their hosting plans. There are also plenty of ColdFusion hosting providers around, but not as many as PHP, so you will need to search specifically for ColdFusion hosting if you want to host a ColdFusion website.

So which one to use?

Most of today's web applications combine client-side with server-side scripts. So it's not a matter of client-side vs server-side.

It's usually a matter of choosing which client-side scripting language, and which server-side scripting language to use. In most work environments, this choice is often made for you. The team uses certain technologies for most of their projects, and any newcomers are expected to be conversant with those technologies (or willing to be trained).

However, depending on the environment, and work requests, you may be forced to learn a new scripting language in order to satisfy a client's request.

But if you're new to scripting and you don't know where to start, start with JavaScript. JavaScript is the most popular client-side language on the web. Once you learn JavaScript, try a server-side language such as PHP or ColdFusion. Your knowledge of JavaScript will make it easy to learn the new language.