health care, road trips, tech talk, occasional rant

CSS -> JQuery

In the early 00’s I had an all-too short gig (*) wherein I got very good in Javascript — a C++ CGI application for displaying complex web traffic data in a home-grown Javascript-driven hierarchical tree.   I made a clever decision to negotiate for standardization to Microsoft Windows IE as the browser.  The plausible logic was that we were selling our product to serious business types, who in 2001 were very predictably Microsoft Office-based enterprises running IE on Windows 2000 networks of PCs, so who needs anything else?

Now for you readers who were 14 at that time, Windows IE was by far the coolest browser then.  Now, when I am writing this – 2010 – I feel the same way about IE that I do about the goose poop in the park I walk through every day, but back then, it had a pretty complete home-grown DOM and way more effects – fades and gradients and such – than did Netscape or Mozilla or any of the other then hot browsers; so I was able to make a qualitatively slicker application by committing to that single browser platform rather than dumbing down the features to stuff that would work across platforms.

Why am I telling you this?  Other than some old-guy desire to yak about things I’ve never had a forum to yak about before?  well … JQuery, and in particular JQuery effects offer a plausible platform-independent way to do many of the things I did then, without having to whore for Microsoft to get them done!  Just write the damn code, and it will work on Firefox and Opera and Safari, and if you’re lucky, maybe even IE, so you can move on to the next task, instead of burning half your working life testing browser incompatibilities on the previous task.

I discovered JQuery a couple of months ago, and fell quite in love with it.

  • first there is the excellent syntax.  I can envision having the bright idea to make a function to do “whatever” to your page based on CSS selection rules, but that simple $() syntax is just frigging awesome!
  • then there is the “one/many” convention that kinda falls out of the previous great idea — the actions in your function are applied to whatever group of elements you have selected – duh.  So if you follow CSS conventions and use id only for single items, and class for many items, then $(“#thing”) operates on one thing and $(“.thing”) operates on many things.  Also there is a .first() function if you really do want to operate on just one thing when you might get many things.  But my point is that removing the trailing-edge distinction between doing it to one and doing it to many is really clean and cool.
  • then there is the chaining thing — in plain ole Javascript, sequencing things that carry on asynchroniously is a big pain in the ass, and truth be told such things are still a pain in the ass in JQuery (see below), but not nearly as much so as without JQuery, because you can simply chain JQ functions which implies that the next one doesn’t start until the previous has completed.
  • oh, and there’s the incredibly simple plug-in syntax, which I don’t feel up to writing about this very second.

Now, having detailed my hot love affair with JQuery, I should update you with the cooling of my passion, with my downgrade to “just friends” with JQuery.

The short version for now (Feb 2010) is that doing stuff with Javascript, and more to the point with Ajax, are just simply more fragile and persnickety than just cranking out the pages with PHP and full page loads.  I did a pretty simple re-do of my resume site with simple Ajax, and that went pretty well, but then I tried a clever JQuery-fication of my gallery browser, and it really, really sucked.  So for now, as a matter of getting a better development bang for my buck I decided to move ahead with just getting stuff done with the tools I know well (PHP and simple full-page HTTP) and not burn cycles on Javascript timing issues and crap like that until I have a product I like and want to make slicker.  so there!

(*) my exit from that job was a classic Dilbert cartoon — six person company: one manager, one genius, one gofer (hi Erica :), three programmers: one database guy, one User Interface guy (me!), one data-cleaning girl to massage the log files for input to the database guy.   … flash forward 14 months and we just aren’t selling the darned thing (let’s blame it on the dot com bust of early 00’s and the fact that our only clients were big time banks whose management was in the (911) Twin Towers), so someone has to go.  Here is the condensed summary of the exit interview:  “John, you did a great job with the UI, it works very well.  But the database and the log file cleanup need a lot of work, so … you are the one to go, because your part of the product is the least in trouble“.