Unobtrusive JavaScripting

Recently I’ve been looking into ways to make my code more maintainable after having to support an old site I did and some Actionscript code from someone else. One of the things I found and REALLY liked was the idea of using Javascripts in an “unobtrusive” manner. Basically all it means is to take out those Javascript event calls like

1
onClick

,

1
onMouseOver

and such from the presentation layer (CSS style sheets and HTML tags), and use other means to achieve the same effects.

What I’ve found useful and have been using ever since are these classes:

1. Prototype
2. script.aculo.us
3. Behaviour

There are tons of extensions and subclasses written for them, making them super useful when you want something done quickly and effectively. I especially like Behaviour for its simplicity and the ability it affords me to completely separate Javascripting from tangling with my HTML codes (hard coded, dynamically generated or otherwise).

There are other useful ones such as jQuery and moo.fx, but I’ve been pretty happy with those other three core packages so far.

Incidentally, Apple’s revamped site also has a lot of new Javascript-driven effects that are pretty interesting to look at and experiment with. Another really clean and simple site I like is Panic’s Coda product site. Really very effective use of Javascripts in presentation.

There’s always so much to learn with so little time… What to do!!