It’s Time To Behave

We are all hypocrites, every damn one of us. Well, actually, just those that are guilty of inline javascript. Now don’t get all puffed up, I’m just as guilty but it’s time to change and I have some tips!

Over the past couple years we’ve heard a lot about separation. Two types, in particular, have been evangelized, data from structure and structure from style. One we don’t hear about nor see it practiced very often is separation between structure and behavior. Why do some of us work so hard at protecting data, structure and style while neglecting behavior?

For me it’s laziness. After designing a site I spend a majority of my time creating a solid structure then styling. By the time debugging is over I’m so beat, a little inline javascript never hurt anybody, right? Wrong! So how can I/we change?

I’m a firm believer if your slacking in something, it’s probably because it’s not as fun as it could be. So in an effort to liven up javascript I’ve decided to investigate a framework called JQuery (http://www.jquery.com). It’s similar to Prototype (http://prototype.conio.net/) but not as bloated, it slides in at a polite 10k when compressed and has a handsome toolset. The best part about it is you find yourself unknowingly abstracting all your code. It’s designed with separation in mind and makes it fun to boot! It also supports XPath (http://www.w3schools.com/xpath/) which I haven’t really dove into yet but I’ve been assured is quite amazing. Aside from its core functionality its provides some simple effects, ajax, and basic events.

So there you have it. We/I have no reason to neglect this important separation of behavior.

UPDATE Two great articles have surfaced on a similar topic: