[whatwg] element.onFocus instead of window.onhashcange ?

Thomas Broyer t.broyer at gmail.com
Sat Nov 21 18:40:14 PST 2009


On Sat, Nov 21, 2009 at 10:33 PM, Bjartur Thorlacius
<svartman95 at gmail.com> wrote:
> Could you please explain to me (forgive me, I haven't got much
> experience on this topic) why "webapps" can't either have a specific
> element for <inbox> and <sent mail>, or even different pages? Why is
> it so terrible to navigate to another page to fetch another mail
> folder? They have to fetch the data from the server anyway.

"AJAX" isn't only about "user experience" (re. "fancy AJAXy stuff"),
it's also about having just data being sent on the wire, which is an
order of magnitude smaller than a full-fledge HTML page.

> And even
> if they wan't to do some fancy AJAXy stuff they can always use the
> HIDDEN attr (or CSS) to hide currently irrelevant parts of the app and
> fill in new data with JavaScript/ECMAScript as it arrives.

OK, so given that I have 15781 conversations currently in my GMail
account, the page then would have the exact same number of hidden
elements so they could be focused "on hash change".
Add to that my 35 labels (peanuts) and the "pages" used to display
chunks of the conversations list (the "all" folder is then 15781 / 50
= 316 pages, my WHATWG label is 46 pages, etc.), and of course those
elements that would have to be created dynamically each time I do a
search in my mails.
And because "focus" events do not bubble, that also means as many
focus handlers (and everyone knows that too many of them has an impact
on browser performance).
Now, compare that to a single window.onhashchange event handler.

> And I think these approaches would be more backwards-compatible than
> rewriting the document with XHR on hashchange.

webapps already use "hacks" to get an "hash change" event of some
sort, window.onhashchange then just makes it easier and identical
across browsers; i.e. easier for the webapp developper. And what is
easier to use is less prone to bugs and the like (do you really
imagine yourself having to manage so many hidden elements and their
focus handler as I counted above my GMail account would need?)

-- 
Thomas Broyer
/tɔ.ma.bʁwa.je/



More information about the whatwg mailing list