The idea behind this Javascript library is great -- it's similar to what I argued for in Why JSP Sucks So Hard. As I mentioned in my post on Ruby on Rails, I still find it grating when I see so much non-HTML code in an HTML page; and the CSS marker system seems like a great way to hook code and markup together. Cheers to the Behaviour folks.

I will note the irony that the original HTML quoted above has inline JavaScript in every anchor:


<a onmousedown="return insertScript('http://oreillynet.com/pub/wlg/2423')"...


Anyway, I had no idea how cutting edge I was, maybe because it never crossed my mind to litter my HTML with JavaScript. In my Sparklines Generator there is only one line of JavaScript in the HTML:




All of the onwhatever behaviours are hooked up on the fly in the setup() function. It wasn't a conscious decision to be cutting edge, but a practical one that followed from my decision to make the application as data table driven as possible.

Not only are we are seeing the benefits of clean structured markup in faster load times and more flexible designs, we are also getting the unexpected dividends of enabling new developments like microformats and now Unobstrusive JavaScript.

Updated: Re-tagged this as 'unobstrusive javascript' to bring it into line with Simon Willison's work on the subject. Also added the further reading section. I may also need to go back and update my Sparklines markup since I used divs instead of fieldsets.

Why are you using <body onload="setup()"> when you can also do it "on the fly"?