Unobtrusive Javascript
I was reading the Slashdot review of DHTML Utopia over breakfast. It set some ideas rolling in my head about unobtrusive scripting.
I use an online RSS aggregator of my own creation to browse through the news. It simply puts all the news items together on several pages, ordered by age. It’s a very simple, time-efficient method.
Since moving the server, I’ve moved the news section to its own subdomain for the purpose of separating its access statistics out from those of the main website—and to make it easier to type into the address bar. I took the opportunity to tidy up a few obvious rough edges—just the very lowest-hanging fruit, however. There are some obvious bugs in the parsing of the double-escaping in Le Monde’s feeds, which have only become apparent since I moved from an unofficial version to their (relatively) new official feed. It annoys me, so I am likely to address that very soon.
On thing that the aggregator has always had is a display of the time and age of each item. In the past, though, the age was correct at the time the page was loaded, but wasn’t updated as time passed. Obviously, after a short while, it was inaccurate and basically useless.
And that is where unobtrusive scripting comes in. Simply by
adding a couple of span
elements around the time and
the age and adding one link to my new Javascript clock code in the
page header, I was able to implement an automatic timer that
updates the age of each item in real time. Simple, but effective,
as you can see.