Tutorial 16: Client-Side Scripting 101 - HTML with Style | 3 | WebReference

Tutorial 16: Client-Side Scripting 101 - HTML with Style | 3

index12345678

Tutorial 16: Client-Side Scripting 101

Scripting Ethics

Regardless of which language you use, the question that arises is whether or not to use scripts and what to use them for.

JavaScript has become quite powerful in recent times, and can be used for a lot of things. Many people have developed entire interactive applications using only Web pages sprinkled heavily with plenty of JavaScript. Should you do this too?

Personally, I believe you shouldn't. My views on the subject are laid out in more detail in a related Style Watch article which you might be interested in. In short, the problem with JavaScript is that it is not as widely supported or standardized as we'd like it to be, nor is it powerful enough for most uses.

Scripts can be used to add interesting and useful effects to Web pages much like style sheets can be used to add good-looking presentation. However, it is my conviction that an HTML document is first and foremost a document, and that it should be able to exist independantly as a document if you remove all of the presentation and special effects. Using JavaScript to create powerful navigation is OK, as long as you have good old-fashioned links as well. Using JavaScript to create presentation effects such as fade-ins and scrolling text is OK, as long as the document can be displayed as a plain old document too.

What you should never do on the Web is create a Web page or a set of Web pages that rely on scripts to be useful. If you want to create an interactive application on the Web, use something like Java or ActiveX. Even if you ignore the ethics of creating broken Web pages, technologies such as Java and ActiveX are much more suited to creating Web-based applications than HTML with JavaScript, and you will find that it's a lot easier to use them.

If you create a Web page that relies on scripting to be functional, it means this Web page will (a) be inaccessible to people whose browsers don't support scripting or who have disabled scripting in their browser preferences and (b) probably be completely meaningless and confusing to these people.

So don't. Scripts are nice, but make sure they do non-essential things. Above all, make sure all of the information available in your document is available even if you remove all scripts.

Moral warnings aside, let's get down to the actual nitty-gritty.

index12345678

URL: http://www.webreference.com/html/tutorial16/2.html

Produced by Stephanos Piperoglou
Created: September 15, 1999
Revised: September 27, 1999