[thelist] Autofocus usability issues tackled

Lee kowalkowski lee.kowalkowski at googlemail.com
Fri Oct 13 11:28:42 CDT 2006

On 13/10/06, Matt Warden <mwarden at gmail.com> wrote:
> On 10/13/06, Lee kowalkowski <lee.kowalkowski at googlemail.com> wrote:
> > Some documents can take ages to load, and a few never
> > completely load (shame on them though).
> Not always their fault :)

Hehe, dunno, if instead of "never", it's "sometimes never", then I guess not.

> But then you've got script tags all over your document, just for
> execution order purposes?

Only to illustrate a point, in practice I'd just use one "framework"
style script element before the closing body tag.

> Take a look at onAvailable (link above).
> Most other (good) libraries have something similar, too.

It's great that libraries offer these things, people can spend less
time on the fundamentals and more time doing the sexy stuff, as long
as they don't mind launching timeouts/intervals that poll for DOM
elements 20 times/second (OK it's configurable, but does the average
user bother?).

> But then you've got script tags all over your document, just for
> execution order purposes?

But then you've got onAvailable calls all over your code, just because
you don't know/care when the DOM is going to be ready?  If you're not
cautious, you could easily get up to 2000 timeouts/second waiting for
everything and its dog, but if your users have got decent machines,
they should be alright shouldn't they?  You could just execute your
code the once when you know the DOM will contain your elements.

Good pointer never-the-less, onAvailable would solve the usability
issue with setting focus on form fields just as well, but Christian
already said that in his article.

The argument in Christian's article about needing an even better
solution than onAvailable is that under certain circumstances there's
still a chance of it being invoked too late, but there's limited
mileage here, perhaps more prevalent in very large documents.

The majority of the form field auto-focus usability faux pas are
caused by using window/body onload, which doesn't fire until all
accompanying resources (e.g. images) have loaded.


More information about the thelist mailing list