Dynamic HTML: Converting the Java Faithful

John Swenson
MSDN Online

October 27, 1997

In the months leading up to the release of Internet Explorer 4.0, Microsoft began urging developers to create Web pages and applications using a combination of Dynamic HTML, HTML, and scripting. Such browser-based applications can match or surpass almost any interactive content you can build with a Java applet, the company promised.

Not surprisingly, some people reacted skeptically to this message, especially developers who believed the sales pitch that Java was becoming a platform. I watched Charles Fitzgerald, a program manager on Microsoft's Java team, tell a roomful of people at the Java Internet Business Expo in New York in late August that Dynamic HTML was a better cross-platform solution than Java. His comment triggered a round of snickers and smiles, as Java fans in the audience reacted with disbelief. As a member of the press at the time, I also remember being skeptical that Dynamic HTML could replace Java, in part because I still didn't understand all the things Dynamic HTML can do.

In retrospect, it's easy to understand why people initially were skeptical of Microsoft's message to skip Java and go directly to Dynamic HTML. This is such a new technology that many developers are just now beginning to understand it. And since Dynamic HTML and Java are such different technologies, comparing them can be awkward.

Some answers

Now that I'm working for Microsoft, I decided to ask around the company and learn exactly what Dynamic HTML can do. After talking with several Dynamic HTML and Java developers at Microsoft, I've rounded up the answers.

The biggest advantages of Dynamic HTML are not just that it can accomplish tricks a Java applet or ActiveX control can't match, but that it's much easier to use and more cross platform than those technologies. Creating Java applets and ActiveX controls requires full-fledged programming skills, while Dynamic HTML just requires the author to understand HTML and a scripting language. Microsoft estimates that there are over five times as many HTML authors as Java developers worldwide. So, there are many more content providers and developers with the skills to use Dynamic HTML rather than Java.

Microsoft created Dynamic HTML and decided to support it in Internet Explorer 4.0 because the company saw the need for an easier way to create really interactive and engaging Web pages and applications. "What we really wanted to do is make Dynamic HTML the easiest way to make your Web pages come alive" explains Michael Wallent, Microsoft's lead program manager for Dynamic HTML.

In addition to its ease of use, Dynamic HTML also is a better cross-platform technology than Java. It downloads quicker and runs faster than Java applets, especially on Windows 3.1 and older, 68000-series Apple Macintoshes. If you've ever drummed your fingers while watching the little "Java applet initializing" message in the bottom of your browser, you'll understand what I mean when I say Java can be slow. When you open a page with Dynamic HTML, there's almost no waiting, once the page has downloaded. And Dynamic HTML will run on all versions of Internet Explorer 4.0, including the Windows 3.1, Macintosh, and UNIX versions.

A better user interface

Because Dynamic HTML is just HTML and script, it can't do everything an ActiveX control can, such as accessing operating system services. If you want to access the Windows registry or print something, for example, you'll still need an ActiveX control. But Dynamic HTML does have some advantages of its own. It's an ideal technology for creating any sort of user interface element in a Web page or application, says Scott Isaacs, author of the forthcoming book Inside Dynamic HTML, from Microsoft Press. "Most stuff that's UI-based should be done in Dynamic HTML," he says.

Simply by adding a little script to your HTML pages, you can create such sophisticated elements as outlines that expand or collapse at the click of mouse. The text will even automatically reflow to fit the new length of the column. And there are a wide variety of mouse-over effects you can accomplish with Dynamic HTML, such as making fonts change in size or color. (To view examples of this and more, visit the Dynamic HTML Gallery on the SiteBuilder Network.)

More efficient than Java

Dynamic HTML is able to accomplish its tricks because it provides a comprehensive object model for HTML. This model exposes all page elements as objects that can be manipulated easily, simply by changing their attributes or applying methods to them at any time. This makes Dynamic HTML more efficient than Java, because it doesn't have to start up the Java virtual machine. What's more, Dynamic HTML doesn't require any return trips to the server to work its magic. Once you've downloaded the Dynamic HTML information for a page into your browser, you can modify text or graphics on the fly simply by mousing over items or clicking on them. To add Dynamic HTML to a Web page or application, developers or Web authors can use any scripting language. Some of the Dynamic HTML experts here recommend ECMAScript (the standards-based successor to JavaScript), especially if you're putting your Dynamic HTML application on the Web, where JavaScript is widely used. If you're more familiar with VBScript, then use that, they advise.

It's all about the DOM

When you break Dynamic HTML into its individual features, you'll find that they are based on the Document Object Model. The DOM makes HTML and Cascading Style Sheets (CSS) programmable through script. Since the W3C is standardizing the DOM (for details, see http://www.w3.org/Press/DOM-core.html) and Microsoft is working very closely with the W3C, you don't have to worry about getting locked into proprietary technology.

Dynamic HTML supports a host of other features I haven't even touched on, such as data binding, which adds the ability to sort tables and other data right in the browser, without requiring a return trip to the server. Dynamic HTML also lets you lets you create reusable components called scriptlets. As developers create more Dynamic HTML applications, the number of these reusable scriptlets should grow dramatically.

No more snickering

With a little research, I've learned enough to overcome my initial skepticism about Dynamic HTML's ability to substitute for Java when developing interactive content. (My newfound enthusiasm has nothing to do with joining Microsoft, really!)

As developers move more and more applications to the Web, they'll want to add life to their pages and give them all the capabilities of a full-scale desktop application. The ease of use, speed, and cross-platform capabilities of Dynamic HTML let them do that without compromise. As this new technology gathers steam, it will win many converts from the ranks of the Java faithful.