Libraries Remove the Madness from JavaScript

by Reuven Lerner - Mar. 18, 2008Comments (0)

Back in 1995, while I was working for Time Warner's Web division, someone showed me the latest technology advance to come out of Netscape, then the hottest company. It was a language called "LiveScript," and it was a programming language that worked within the browser.

No one really knew what we could or should do with such a thing, other than some rudimentary checking of forms before they were submitted to the server. But we all agreed that this had a great deal of potential.

LiveScript had the unfortunate luck of being introduced at around the same time as Java, which was then being used primarily for applets. Netscape agreed to put Java into every copy of its Navigator browser, thus ensuring wide distribution for this new technology. As part of this deal, Netscape renamed "JavaScript," which was also included in their browsers.

Many years have passed since this happened, and the names "Java" and "JavaScript" continue to confuse non-programmers. Java applets are relatively rare now, as Java has become more popular for server-side technologies. JavaScript has been standardized to a great degree, and is now officially known as ECMAScript, with implementations in various browsers.

For many years, Web developers -- myself included -- had a love/hate relationship with JavaScript. On the one hand, it was a very useful language, because it turned the browser into something more than a glorified dumb terminal, offering the tantalizing possibility of creating interesting applications that didn't have to check with the server for each mouse or key click. At the same time, the different implementations of JavaScript were similar, but far from identical. These differences made it maddening to use JavaScript.

Over the last few years, JavaScript has gone through something of a renaissance. (JavaScript devotees will likely say that server-side snobs like myself simply saw the light, after years of ignoring the reality.) The standards have become better, giving JavaScript unprecedented power. The implementations have begun to adhere to the standard more closely, allowing developers to create applications that are increasingly cross-platform. And the growth of the "Ajax" paradigm for Web application development, in which the entire page does not need to be refreshed each time a link is clicked, has pushed JavaScript to the forefront of Web technologies.

What is perhaps the most intriguing development in the world of JavaScript is the number of high-quality, open-source libraries. If you're interested in creating Ajax-based Web applications, you can definitely do that with raw JavaScript. In fact, it's probably a good idea to do that, just to understand what is involved, and how things are working behind the scenes. But once you have a basic understanding of what's going on, then you will almost certainly want to use a good library.

A good library will mask the differences between browsers (and browser versions), allowing you to concentrate on your high-level code. But most libraries also provide a large number of convenience functions (such as $, which gives direct access to elements via their ID), special effects, and Ajax functionality.

I'll discuss these libraries in greater depth in the future, both individually and in the context of interoperability (which is one of their weak points). But if you're thinking of writing Ajax applications, then you should investigate these libraries, and choose one as the basis for your work:

I'm sure that I have forgotten to mention one or more popular open-source JavaScript libraries. Which is your favorite, and why?



D J uses OStatic to support Open Source, ask and answer questions and stay informed. What about you?




Comments

image
Share Your Comments

If you are a member, to have your comment attributed to you. If you are not yet a member, Join OStatic and help the Open Source community by sharing your thoughts, answering user questions and providing reviews and alternatives for projects.