Posts from October 2008

Keeping your Javascript clean

I've been doing a bit more Javascript recently, specifically using Prototype AJAX stuff with Google Maps ,and I've come up with a few guiding principles that have helped me keep stuff neat and tidy. I thought I'd share them with you, my handful of readers.

SCRIPT tags should live inside HEAD

There are very few reasons for having SCRIPT tags inside the document body. The main one, use of document.write() nearly always leads to ugly code. It's also not actually allowed in XHTML, despite most browsers accepting it as long as the page is delivered as text/html.

Furthermore, SCRIPT in the document body is in my opinion always the result of a perceived problem that's actually the result of poor architectural choices.

How much of your data is available online?

One of the emergent web technologies I'm very interested in is the Microformats project, a set of ways of making data embedded in HTML documents machie-readable.

Two of the most widely adopted Microformats are hCard and XFN.

hCard is a standardised method for marking up contact data. the point of it is that if all sites mark up contact data the same way, it's easier to parse.

XFN is all about the relationships between sites, and one of its key features is that it allows you to identify that a set of online profiles all belong to the same person (if they've voluntarily linked them).