The Pencil Guy: Hourann's illogical blog

In the innards of upcoming new toys

Wednesday 15 November 2006 at 10:05 pm

As in previous cases, the lack of posts is a sign that announcements are forthcoming. Although in this case, they may not be all that rapidly forthcoming, because I’m still busy wading through, er, bugs. So rather than the other things I was going to write about today (such as the constant sound of planes practicing for the Red Bull Air Race), I think I’ll rant about JavaScript libraries.

The library that is getting all the Apple-style (or more appropriately, Rails-style) love among the fashionable developers is Prototype.js, which is awesome and something that I can’t believe I only discovered recently. If nothing else, $() is like manna from heaven. (well, sort of. And yes, it’s ridiculously easy to re-implement … but I wish I’d thought of it myself or something!)

The problem with Prototype is that it’s enormous — over 60kb of code that I was tacking on to pages of barely 12 or 15 kilobytes. Even with compression (e.g. via Dojo ShrinkSafe) it still weighs in at 25kb, which is a decent download for the lowly dial-up users out there. And that’s before you count the 50 to 100 kb of script.aculo.us, which is breathtakingly easy to use but not that well optimised.

So I find myself gravitating towards mootools, which packs an awful lot of punch into a customisable 10 — 20 kb script. Unfortunately, the mootools documentation looks pretty but is profoundly lacking in examples (making it hard to get started) and is also short of detail in a few places that have become important for me. (Hence, another contender is jQuery, which is well-designed and has better documentation … but isn’t quite as full-featured out of the box as mootools.)

I briefly inspected MochiKit and Dojo, which are both nice, but don’t quite do what I want, and are hardly lightweight themselves. It looks like mootools is it for now!

no comments »

SELECT objects in the HTML DOM = no fun!

Tuesday 3 October 2006 at 10:57 pm

Random JavaScript discovery of the day: suppose you’re working with a <select> drop-down menu in Firefox, and you want to play with the items in the menu.

You might try to use the objects method: document.getElementById("mySelectID").objects … with the expectation that you’d have an array, because that’s what most of the non-official documentation says. But they’re wrong! (or at least out of date?)

What you get pretends it’s an array — you can pick items by index and use the length property — but it’s actually a crazy DOM object called HTMLOptionsCollection. Thus you can’t use funky array techniques like Firefox’s new(ish) indexOf method to search it. That’s a bummer, because JavaScript has no other way (AFAIK) of searching an array by value.

In other news, having coffee with the lawyer-ey portion of the honours crowd after our seminar today was the coolest form of procrastination I’ve done in ages. And yay for Julia’s fifteen minutes (or thereabouts) of exuberant fame :-)

no comments »