The New Timers
Written by on April 1st, 2007 in Ajax News.

Ask any self-respecting Ajax developer how they time events, and they’ll tell you “I use setTimout()” or more likely, “I use setTimeout(), duh”. However, two new Ajax patterns are making that “duh” seem just a little tenuous. One new timing technique relies on the notorious <blink> tag, the other is all about the whitespace. That’s right folks, setTimeout() is about to go the way of the fob watch.
- <blink> timing For a long time, the ignoble <blink> tag seemed destined for all the one-hit wonderness of a Vanilla Ice or an MC Hammership. Loved for a month or two, then cast aside with nought but the occasional fond memory. Yet in an unanticipated turn of events, intrepid developers have recently been asking hard questions about <blink>. “If it was really as dumb as people make out, why was its timing so precise?” asked one Ajax guru who wished to remain anonymous on the grounds that he had been consuming Red Bull for the past eight hours. Another guru in questionable state pointed out “setTimeout() isn’t all that! Did you ever try it in lynx? Total no-op!” And so it was that <blink>’s true purpose became known. Reborn as much out of frustration with setTimeout as it was with the promise of a more robust solution. No longer eye candy, but a super-precise timing mechanism. The thinking geek of 2007 embeds a single <blink> tag on the page, hides it with CSS, and arranges all application scheduling against the swift oscillations of this postmodern crystal timer.
- HTML whitespace. If you’re still working in Ajax 1.0, you probably haven’t paid much attention to the biggest portion of your HTML - the whitespace. But then, three-quarters of the world is water, and where do we devote all our attention? So it’s hardly surprising that whitespace’s virtue has largely gone unnoticed. In design, getting whitespace right is a vital task, and likewise in modern Javascript code, whitespace is everything. The secret of HTML whitespace is that programmers can use subtle variations to affect speed of processing. Say you have a script that needs to interact with an element of your page. The old, clunky, way would be to rely on document.onload. The new way is to output the element first, followed by 1-2MB of whitespace, followed by the script tag. By the time the whitespace has been processed, the element will have been placed on the page. You may object to all this whitespace consumed by this hack, but bandwidth is cheap these days and IDEs can hide it while you’re developing. So what’s the catch now, wise guy? With the trend towards parallel computation, whitespace promises a way out of the concurrency and synchronization headaches that Ajax developers often endure.
We’ve yet to see these facilities live, but then we haven’t yet seen Vanilla Ice live either and he’s doing just fine. setTimeout() is dead, long live the <blink> tag!
Source: Ajaxian
Original Article: http://ajaxian.com/archives/the-new-timers