Christian Heilmann

You are currently browsing the archives for the Odds & Ends category.

Archive for the ‘Odds & Ends’ Category

Dear JavaScript Library Developers…

Monday, December 11th, 2006

After spending about three weeks finishing a chapter of the upcoming book introducing JavaScript libraries to non-developers I was quite amazed how tough it is at times to use different libraries.

It was frustrating putting together a set of example scripts for several effects for the oddest reasons, which is why I am now publishing my wishlist for any JavaScript library developers or maintainers. Before you start a new library or expect people to be able to use yours immediately you might want to give these points some thought. For library users this list might be a good “heads up� to see how much work has to go into using a library or how to pick the right library for the job at hand.

Here’s what drove me nuts:

  • Lack of offline documentation. I am writing a lot of code on public transport or in hotel rooms where they consider it still an option to charge me for every 10 minutes online. It is not hard to create a PDF or offer a ZIP of the library documentation even if it is Wiki based.
  • Lack of step by step instructions and examples for effects and elements of the library. Most of the time you either get no examples at all or a single example that shows all the options you have in one script (or a very complex form to play with all of them – which is only marginally better).
  • Lack of unobtrusive examples of code which are those that fall back to working and functioning HTML or HTML+server side script solutions. In the market you will have to develop applications in accordance with accessibility and SEO requirements and both of these require that the page does not rely on JavaScript. It is very easy to create fancy examples that work with JavaScript, but harder to enhance what is already there.
  • There is no problem with trying to improve JavaScript or DOM methods in addition to just fixing bugs and browser inconsistencies. However there is a problem if your extensions break conventions like the event model. I have encountered a library that had addEvent() and removeEvent() methods, but no way to stop the default behaviour of the element. This is an oversight that shows me that this library was never meant to be used unobtrusively or to enhance a server side driven application.
  • Lack of information about browser support and – even more importantly – fixes and updates for new browsers that might come along. This allows your users to update their library includes or subscribe to feeds that tell them about updates and fixes. As a lot of libraries advertise themselves as a helper to make sure you don’t need to know JavaScript this is the least you should do to gain the trust of users. It is easy to claim everything works, but when there are browser specific bugs you cannot expect library users to fix them inside your library.
  • Inconsistency in naming of methods and properties. There is a lot of good documentation on the W3C sites about what an event is, and if you call it action I personally get very confused. If you don’t know JavaScript or the W3C specs that is less of an issue but personally I consider libraries are step towards improving JavaScript and the DOM and not a replacement of them.
  • Trying to replace CSS with library methods. There is a reason why CSS is used for look and feel: CSS parsers are very fast and it is great for maintenance to centralise all look and feel in a spot using one technology. CSS is that technology as it was invented for it. Instead of battling CSS, scripting should piggyback on the CSS parser whenever possible (by adding CSS class names to parent elements) instead of changing a lot of style properties directly. CSS has a lot less options to access content and elements than the DOM has and we can use JavaScript to give CSS developers a helping hand to reach these. There is a reason why there are so many “CSS onlyâ€? solutions out there – people got sick of scanning JavaScripts to find the place to change a look and feel parameter.
  • Don’t play the “mine is smaller than yoursâ€? card. It gives the wrong impression to new developers as they might be tempted to think that your short wrapper methods are all that has to get executed. We all know that they have to be converted to native JavaScript and DOM methods before execution.

Tip: Do not position Google Ads absolutely!

Thursday, November 23rd, 2006

I was amazed to retrieve a cease and desist email from Google Adsense about my ads on this blog the other day. Allegedly I violated their terms and conditions by using advertising in a floating layer (you know the ones that cover dodgy pages before you can use them).

The reason they thought of me that way was that I had a skyscraper ad on the right hand side of this content section positioned absolutely. I also had a JavaScript in place that would hide the whole ad section on browser sizes that are too small to accommodate for it.

However, as the Google compliance testers seem to turn off JavaScript and use a very small browser window when doing their checks, my ads overlapped the content and I became an outlaw.

So remember that when you use AdSense for your web sites don’t position them absolutely but float them or use negative margins instead or else you’d also have to face being banned from the system and get three days to rectify your mistakes.

Explore flickr tags and photos with flickrdrillr

Friday, November 3rd, 2006

I played with JSON, event delegation and the APIs of flickr for the upcoming hack day and thought it’d be fun to explore flickr only by tags.

Using the YUI, I put a small example together that allows you to search for a tag, get all the other tags entered by flickr users and see the photos related to the current tag. You can then click the next tag, get the related tags for this one and so on and so forth.

Have a play and check out flickrdrillr now

Hours of fun with Google Code Search

Thursday, October 5th, 2006

As [link:, informs us] the new [link:,Google Code Search] already unearthed a lot of interesting things, like WordPress logins, a key generator for Winzip and even something [link:,totally unexpected] .

Update: [link:,Predius also analysed with the search how many f*cks per language and package are in use]. PHP a clear winner there.

Silly Browser Trick: V for Firefox

Tuesday, October 3rd, 2006

A colleague just found this by chance: If you type “v” in the browser location on firefox and hit enter you’ll end up on the V for Vendetta homepage. Incidently I just bought the DVD and loved the movie to bits. But how does it work? (more…)