3.1. Using JavaScript on the Client

The JavaScript language can be used independently of the browser. There are JavaScript interpreters for managing operating system components, interacting with COM objects, and automating server administration tasks. To use JavaScript in the browser, you should be aware of a few considerations.

First, you need to manage getting the script to the browser for a page effectively. As the amount of JavaScript you use grows, you will want to make use of the browser's ability to cache scripts for performance reasons. You also need to be aware of how the user's interaction with a page while background operations are performed affects the user's perception of the page's performance. In some conditions, you want your users to know that they are waiting for an action to be performed so they don't become frustrated, and in other cases, you want to ensure that the page is responsive while something happens transparently in the background. In addition, JavaScript resources can be embedded directly in a DLL and do not have to be deployed as text files on disk, as you might be accustomed to doing.

3.1.1. Getting JavaScript to the Browser

Before diving into the fundamentals of the language, you should understand how JavaScript code gets to the browser as part of a Web application. The HTML script tag is used to separate the script code from the markup, so the browser will be able to distinguish the difference. Listing 3-1 shows the two possible methods for including ...

Get Professional ASP.NET 3.5 AJAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.