Need of Client Side Scripting
There are various reasons for client-side scripting, but it can pretty much all be stated as “browsers and client machines are faster and bigger and more powerful than they used to be. Use that capability – only do things on the server that require server-side resources to do, or that cannot be done more quickly and easily on the client”. This has a number of benefits:
- It allows the server to serve more clients with the same system resources, since some of the stuff it used to do (laying out the HTML for each page after a request, for example) is now being done on the client
- Other than sending the original resources (images, CSS, HTML, JS files) to get the page up and running, the only thing that needs to be sent later is the data that changes as the user uses the site/application. This cuts down on network traffic, which again allows more clients to be served.
- Many things that clients do don’t actually require a round-trip to the server. For example, showing a drop-down menu can be done with client-side scripting easily, assuming you have some idea of what menu items need to be displayed and how they are organized (which itself is really data – it doesn’t have to be hard-coded as HTML). Given this menu data, there’s no real need to ask the server to do anything at all. Another example is client-side verification of user input (e.g., when entering an email address, the client script can verify that the format of the address is valid. It can then leave it to the server to verify that the actual address itself exists, if necessary).
- It’s *much* faster to do interactive things only on the client, instead of requiring a round-trip to the server (animations, button-press visual changes), timed events, etc.
Server Side Scripting Language
Server-side scripting is a technique used in web development which involves employing scripts on a web server which produces a response customized for each user’s (client’s) request to the website. The alternative is for the web server itself to deliver a static web page. Scripts can be written in any of a number of server-side scripting languages that are available (see below). Server-side scripting is distinguished from client-side scripting where embedded scripts, such as JavaScript, are run client-side in a web browser, but both techniques are often used together.
Server-side scripting is often used to provide a customized interface for the user. These scripts may assemble client characteristics for use in customizing the response based on those characteristics, the user’s requirements, access rights, etc. Server-side scripting also enables the website owner to hide the source code that generates the interface, whereas, with client-side scripting, the user has access to all the code received by the client. A downside to the use of server-side scripting is that the client needs to make further requests over the network to the server in order to show new information to the user via the web browser. These requests can slow down the experience for the user, place more load on the server, and prevent the use of the application when the user is disconnected from the server.
When the server serves data in a commonly used manner, for example, according to the HTTP or FTP protocols, users may have their choice of a number of client programs (most modern web browsers can request and receive data using both of those protocols). In the case of more specialized applications, programmers may write their own server, client, and communications protocol, that can only be used with one another.
Programs that run on a user’s local computer without ever sending or receiving data over a network are not considered clients, and so the operations of such programs would not be considered client-side operations.
JavaScript
JavaScript often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. Over 97% of websites use JavaScript on the client side for web page behavior, often incorporating third-party libraries. All major web browsers have a dedicated JavaScript engine to execute the code on users’ devices.
JavaScript is a high-level, often just-in-time compiled language that conforms to the ECMAScript standard. It has dynamic typing, prototype-based object-orientation, and first-class functions. It is open and cross-platform and also easy to implement as it is integrated with HTML. It is multi-paradigm, supporting event-driven, functional, and imperative programming styles. It has application programming interfaces (APIs) for working with text, dates, regular expressions, standard data structures, and the Document Object Model (DOM).
The ECMAScript standard does not include any input/output (I/O), such as networking, storage, or graphics facilities. In practice, the web browser or other runtime system provides JavaScript APIs for I/O.
JavaScript engines were originally used only in web browsers, but are now core components of some servers and a variety of applications. The most popular runtime system for this usage is Node.js.
Although Java and JavaScript are similar in name, syntax, and respective standard libraries, the two languages are distinct and differ greatly in design.
Uses of JavaScript
Adding interactivity to website. If you want a website to be more than a static page of text, you’ll need to do some Java Scripting Developing mobile applications: JavaScript isn’t just for websites, it is used to create those apps you have on your phone and tablet as well. Creating web browser based games Ever played a game directly from your web browser? JavaScript probably helped make that happen. Back end development JavaScript is mostly used on the front end of applications, but it is a versatile scripting language so, it can be used on back end infrastructure, too. Some specific uses of JavaScript:
- Client-side validation
- Dynamic drop-down menus
- Displaying date and time
- Validate user input in an HTML form before sending the data to a server.
- Build forms that respond to user input without accessing a server.
- Change the appearance of HTML documents and dynamically write HTML into separate Windows
- Open and close new windows or frames.
- Manipulate HTML “layers including hiding, moving, and allowing the user to drag then around a browser window.
- Build small but complete client side programs.
- Displaying popup windows and dialog boxes Bike alert dialog box, confirm dialog box and prompt dialog box)
- Displaying clocks etc
Features of JavaScript
- JavaScript is an object-based scripting language.
- Giving the user more control over the browser.
- Handles dates and time efficiently
- Detects the user’s browser and OS.
- It is light weighted.
- JavaScript is a scripting language but remember it is not java.
- JavaScript is interpreter based scripting language.
- JavaScript is case sensitive.
- JavaScript is object based language as it provides predefined objects.
- Every statement in JavaScript must be terminated with semicolon (;).
- Most of the JavaScript control statements syntax is same as syntax of control statements in C, C++ or C# language.
- An important part of JavaScript is the ability to create new functions within scripts. Declare a function in JavaScript using function keyword.
Advantages of JavaScript
- It helps you to develop a great front-end as well as back-end software using different JavaScript based frameworks like jQuery, Node.JS etc.
- JavaScript is installed on every modem web browser. For example Chrome, Mozilla Firefox, Safari etc. So to learn JavaScript we do not need any special environment setup.
- JavaScript helps to create beautiful and crazy fast websites we can develop our website with a console like look and feel and give users the best Graphical User Experience.
- JavaScript usage has now extended to mobile app development, desktop app development, and game development. This opens many opportunities for you as JavaScript Programmer.
- In JavaScript there are tons of frameworks and Libraries already developed which can be used directly in your software development to reduce your time to market.
Limitations of JavaScript
- JavaScript is explicitly added to web pages and client browsers, it can exploit user’s system, so malicious code can be executed on client machine.
- JavaScript is sometimes interpreted differently by different browsers. Different layout engines may render JavaScript differently resulting in inconsistency in terms of functionality and interface.
- JavaScript is a very old scripting language running on the machines and there are other technologies which are doing the same thing in place of it (ex JQuery) in a better and easy way.
- If we disable JavaScript in browser, the entire JavaScript code is not run.
- JavaScript file is download on client machine so anyone can read the code and reuse it.
- Client-side JavaScript does not allow the reading or writing of files.
- It cannot be used for networking applications because there is no such support It doesn’t have any or multiprocessor capabilities.
- Cannot access web pages hosted on a different domain.
- Cannot access databases.
- Depends a lot on the browser.
- Inability to use local devices.
- JavaScript can be disabled.
- Not Search Engine Friendly.
- JavaScript cannot protect your page source or images.