November 14, 2008
Follow me on Twitter

Rethinking Javascript

I’ve had to completely rethink my attitude toward Javascript in recent months. My former attitude was, roughly speaking, as follows:

I think this used to be more or less true, but it’s not true any more. My new understanding:

For the stretchtext project I'm working on, I’ve got lots of ugly link markup:

<a href="javascript:void(0);" onclick="expander('.3');return false;">

Naturally, I hid all the crud behind Tinderbox macros: ^do(expander,....). But it's still unsightly. Instead, simple javascript magic lets us write something clean

<a href="help.html" class="expander">

and transform it behind the scenes into whatever cruft we need. This gives us cleaner markup, and another layer of indirection.