Christian Heilmann

You are currently browsing the archives for the Tips & Tricks category.

Archive for the ‘Tips & Tricks’ Category

Have a random weekend

Tuesday, December 12th, 2006

During some research for a new product I just got a cool mashup site sent to me by a colleague. Random Day Out allows you to define a starting location and will add random locations around the area that can be visited in a day.

You get a map, photos, directions to and from each location and a weather forecast. The system is a bit rough around the edges now, but there is a lot of potential in this.

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.

Moved to media temple

Tuesday, November 7th, 2006

After almost four years my free hosting service finally didn’t work out any longer and I was annoyed about the outages and the other clients on the shared box annoyed about the traffic I caused.

So I bit the bullet and got myself a new server for all my sites. I looked around a bit, dropped some mails on thelist and with other bloggers and I decided to go for the grid server offer of media temple in the USA.

I dreaded the move, as over the years I have acccumulated a lot of data connected to 6 different domains. All the more I was very much surprised to see that I was able to get and connect a new domain, shift my data over and reconnect my old domains ( is still on the old server) to the gridserver within less than two hours!

The admin interface of the grid server allows you to define which domains to use, set up the mail servers and webmail interfaces and lets you define whether to use PHP4 or 5 on a per-domain basis.

You can add extra PHP components by altering an add-on to the php.ini and you have MySQLAdmin by default. Urchin is also included, but I haven’t set that up yet, and you have preconfigured WordPress, ZenCart and Drupal in case you want it. I tweaked this WordPress too much to go all fresh and new, but maybe I will at a later stage.

I now also have a proper spam filter and can play with Ruby, which is pre-installed, too. All in all, I am very happy so far and the price of $20 per month seems not to be too high for what your are getting.

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