Behaviour: Using CSS selectors to apply Javascript behaviours

I love reading this:

After all the work of WASP and others to promote clean markup, valid pages and graceful degradataion via css – it sucks that we’re going back to tag soup days by throwing javascript tags into our html.

The better way to do javascript is to do it unobtrusively. PPK and Simon Willison have been recommending this approach for ages. And it’s definitely the way to go. The only problem is that it’s a bit of a pain in the ass.

That’s why I came up with Behaviour – my solution to unobtrusive javascript behaviours.

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.

Of course, there are still plenty of people on the other side of this argument. Maybe it will be the long-standing religious issue of HTML dynamism. I wish some general solution, like the TinyTemplateEngine in Wheat, or even something like ClearSilver, would emerge as a leader so that we could really hear that language-neutral templates are producing clear wins. That story doesn’t get told very often, which is too bad. A monstrous amount of money, in my opinion, is being wasted in the Web economy with pages written to any one, transient template engine.