How did you like the article?
1
How did you like the article?
1

Client-side scripting vs. server-side scripting: a comparison

The internet has always been based on one simple principle: all kinds of content is provided by web servers and can be received by clients via HTTP or FTP. Clients are browsers, of which the best-known ones include Mozilla Firefox and Google Chrome. These can be installed and used on the user’s system. Web servers such as Apache and NGINX, on the other hand, are components of web projects; these are also installed and run in this environment and allow the respective client access to the content.

While static content like typical HTML elements and images can easily be transferred and displayed, dynamic content such as a Wiki, a drop-down menu, or a web application, will only function with scripts. These must be executed and interpreted with the appropriate scripting language, which can either occur server-side or client-side. For this reason, a distinction must be made between server-side scripting and client-side scripting. 

What is server-side scripting?

Server-side scripting is a technique that is used to develop websites and implement dynamic elements and web applications. It’s based on the use of scripts that are carried out by the web server using the appropriate scripting languages when a client requests the corresponding content. The script’s task is often to retrieve the appropriate data from a database and integrate it into the web project. The user accesses these via HTML pages, while the script source codes remain completely hidden. The use of server-side scripts requires the client to send multiple requests to the web server to provide the user with new information. This means, on the one hand, high utilisation of the server's capacity, which has an impact on the response time of the web server, and on the other hand, that an existing connection to the server is indispensable for making use of the web offer.

In the early days of the World Wide Web, server-side scripting was almost exclusively implemented by writing developer programs in C, as well as Perl and command line scripts. These applications were carried out and interpreted by server operating systems, at which time the result could be passed from the web server to the browser via the common gateway interface (CGI). Many modern web servers can now also run scripts directly, i.e. using corresponding modules. Launched in 1995 and based on C and Perl, PHP is the most widely used server-side scripting language today. The following table shows a selection of the programming languages used for server-side scripts:

 

ASP.NET

Java

Ruby

Developer

Microsoft

Sun Microsystems

Yukihiro Matsumoto etc.

License

proprietary

GNU GPL

BSD

Released

2002

1995

1995

Platform

Windows

independent

independent

Programming paradigms

object-orientated

object-orientated

multiparadigmatic

 

Perl

PHP

Python

Developer

Larry Wall etc.

Rasmus Lerdorf

Guido van Rossum, Python Software Foundation

License

GNU GPL and Artistic License

PHP-Lizenz etc.

Python Software Foundation License

Released

1987

1995

1991

Platform

independent

independent

independent

Programming paradigms

procedural, modular, also partly object-orientated

imperative, functional, object-orientated

multiparadigmatic

What is client-side scripting?

Client-side scripting is another technique used by web developers to create projects with dynamic content. Unlike the server-side variant, however, the client executes and processes the programmed scripts, not the server. For this purpose, the scripts are either embedded into the HTML or XHTML document, or written into a separate file linked to the document. If the user now tries to access a webpage or application with such a client-side script, the web server sends the HTML document and the script to the browser, which performs the same execution, presenting the final result. Client-side scripts can also contain concrete instructions for the web browser, determining how it should react to users’ actions, e.g. clicking on a button. Often, the client doesn’t need to re-establish a connection to the web server.

As the scripts are executed in the user’s browser, the user has the option to view the source code – unlike with server-side scripts. In turn, the interpretation of the scripts requires the corresponding script language to be understood by the web browser. There are also various browser extensions available, which can block scripts, as client-side scripting applications, such as pop-ups and web-tracking tools, can have a negative impact on the loading times.

The most significant client-side script language is JavaScript. Developed by the Mozilla predecessor, Netscape, and launched in 1995 with the previous version of the browser, Navigator 2.0 – then known as LiveScript. The script language caught on quickly, eventually becoming the universal scripting language of all relevant web browsers. Shockwave Flash (SWF) is also worth a mention, despite its considerable drawbacks. The object-oriented language is an important component of Adobe’s Flash Player, which for a long time was the measure of all things for videos on the internet. However, with all its security gaps and the introduction of new technology, such as HTML5, the once popular Flash video has now faded into the background. In the early days of the internet, Microsoft Silverlight and Java Applets also enjoyed a great deal of popularity.

In theory, it’s also possible to use other scripting languages for client-side scripting, but the developers of the relevant browsers must choose to support them. There are, however, alternative solutions that allow client-side scripts with other languages. For this purpose, the respective code can be interpreted and executed as JavaScript using a transpiler like CoffeeScript or TypeScript.

Client-side scripting vs. server-side scripting

The location of the scripts has considerable influence over a web project’s structure; the more scripts that are transferred to the browser to deal with, the more ‘streamlined’ the website or web application becomes for the server. In doing so, server resources are relieved of a considerable burden, although this can result in some losses for the user. Moreover, developers are confronted with increased complexity when only using client-side JavaScript, because this requires replicating many of the mechanisms of powerful frameworks, such as ASP.NET MVC. Further problems can arise because client-side scripting requires the respective browser to support all script languages and features installed by the user, without any blocking applications.

To avoid overloading the client and the server, a strong combination of server-side scripting and client-side scripting is advised. Additional measures will ensure the best possible loading times for your web project, such as caching static content, and using advanced technology, such as AJAX. The latter concept, which stands for 'Asynchronous JavaScript and XML’, describes the method of asynchronous file transferal between the client and server. The web server can react to requests and user input almost instantly without the need to load the site all over again and exchange data with the browser. Google Suggests is a classic example of AJAX technology; this feature comes up with suggestions that automatically appear as soon as they’re entered into Google.

Network HTTP Browser