JavaScript
JavaScript is a simple programming language used to make Web pages do special things—render special effects, pop up alert boxes, and offer options to the user. You can think of JavaScript as an enhancement to HTML.
The difference between JavaScript and most other programming languages is that a JavaScript program is executed by the user’s browser, not by your server.
Most programs that Web developers write are server-side programs: a program on the website’s server takes in information from the user, processes it, and returns a custom page to the user. JavaScript code, however, is inserted into a Web page’s HTML and runs without the page needing to reload.
Despite its name, JavaScript is not a version or component of Java.
Advantages
- Special effects: JavaScript allows for some special effects that can’t be created through HTML alone, such as having photographs on a webpage fade in and out.
- Interface speed: JavaScript can make for faster interfaces, because it avoids the delay of sending information to the server, having the server process that information, and receiving back the result. For instance, a Contact Us form can include JavaScript code to check that the email address is valid. If the address doesn’t have an @ sign, or if other required fields were left blank, the JavaScript code can instantly display a message to the user so s/he can correct the problem. Without JavaScript, it might take a few seconds for the server to do the same thing–long enough to interrupt the user’s experience.
Disadvantages
- Browser differences: Different browsers support different JavaScript commands, so several combinations of operating system and browser must be carefully tested.
Choosing JavaScript
When special effects or rich functionality are needed on Web pages. Most pages that interact with the user can benefit from JavaScript enhancements.