Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

The <script> Tag 473

17


Ease of Use


JavaScript is a real programming language and is regularly used to build large, com-
plex applications, including some you’ve probably seen, like Google Maps. At the same
time, compared to many other programming languages, it’s very easy to get started with
JavaScript. You can add useful behavior to a web page with just a little bit of JavaScript
added to the onclick attribute of a link or to a script tag at the top of an HTML docu-
ment. And as you’ll learn in Lesson 18, jQuery makes it easy to add functionality to a
page using just a few lines of code. The point is, don’t be intimidated by JavaScript. You
can start accomplishing things almost immediately.


Improving Performance


One of the main advantages of JavaScript is that it can provide user feedback instantly.
Instead of requiring users to submit a form to see if their input was valid, you can let
them know in real time. Not only can this improve user experience, but it can also make
life easier for your server by preventing unnecessary form processing on the server. You
can also use JavaScript to load resources when they’re needed rather than when the page
first loads. For example, you can load images that are not displayed immediately after the
page loads to display the site more quickly. You can also use JavaScript to alter only the
parts of the page that need to change when users interact with it. For example, you can
process a search form using JavaScript and display the results on the same page so that a
page reload isn’t required.


Integration with the Browser


JavaScript enables you to manipulate objects on the page, such as links, images, and
styles. You can also use JavaScript to control the browser itself by changing the size of
the browser window, moving the browser window around the screen, and activating or
deactivating elements of the interface. Technologies like Flash can provide an interactive
interface, but they are not integrated into the browser in the same way that JavaScript is.


The