JavaScript
JavaScript is a widely used tool for web scripting, and was originally developed by the Netscape Communications Corporation under the name LiveScript.
One of JavaScript's most prevalent uses is in AJAX (Asynchronous JavaScript And XML) applications. AJAX is one of the principle technologies behind DHTML, a technology used for dynamically editing a web page after it has been delivered to a user's browser.
Features?
JavaScript, like it's similarly named cousin Java, inherits much of it's syntax from the C programming language. As is the case with most scripting languages, JavaScript is weakly-typed. This means that one variable could be used to hold an integer value, then a string value, and so on, without the casting necessary in strongly-typed languages like C#.
Drawbacks
Perhaps one of the biggest concerns with JavaScript is the frequency with which the applications written in it are exploited. Of course, this is probably more due to programmer error than inherent susceptibility to exploits. Another concern arises if a website depends too much on JavaScript for such things as navigation and/or form validation. Given that JavaScript exploits are so common, many advanced
users disable JavaScript in their browsers. My biggest gripe stems from the fact that not all browsers implement the same version of JavaScript, Safari (from Apple, Inc.) being the worst offender.
Notes
To use JavaScript in a web page, it must be embedded in that page or linked in somewhere the document. Which method you choose depends on how your script executes. Some examples follow.
• samplepage.html. JavaScript linked in document head.
<html>
<head>
<title>Page Title Goes Here</title>
<script type="text/javascript" src="js/script-one.js"></script>
</head>
<body>
</body>
</html>
• samplepage.html. JavaScript embedded in document.
<html>
<head>
<title>Page Title Goes Here</title>
</head>
<body>
<script type="text/javascript">
...
</script>
</body>
</html>
As you can see, there is a <script> HTML tag we use for adding JavaScript to our page. This tag isn't limited to just JavaScript, however. You may also specify EMCAScript (the official standard on which JavaScript is based) and VBScript. Also, you will notice that <script> tags linked in the head of the document require an extra src attribute, where we specify the URL to where the external script is stored.
A Warning
Where you place your JavaScript link can actually affect the performance of your website. Some browsers (I'm looking at you, Internet Explorer) will not display the page until the script has been parsed, so if you have a long script, or the source serving the script is experiencing lag, you can suffer a noticable hit on your site's responsiviness.
If the script is not writing directly out to the DOM, you can move your script tags to the footer area of your page(s). You can also add a "defer" attribute to the script tag. This "defer" attribute tells the browser's rendering engine that execution of the script can be safely delayed until the rest of the page has been rendered.
