Ten good practices for writing JavaScript in 2005

Share this article

Bobby van der Sluis has put together a guide to Ten Good Practices for Writing Javascript in 2005. I suspect that most of my readers here will already know that we should be doing this stuff: Bobby talks of making your pages accessible using unobtrusive Javascript, writing scripts that are easy for other developers to apply, future-proofing your work with object detection. This is all sensible stuff; read his article for more. The key point is that there is a difference between knowing that we should be doing this stuff and actually doing it. All too often I find myself quickly and temporarily chucking in an onclick attribute on a tag, rather than attaching the event handler properly from JavaScript, and I’ll bet a nice shiny Bank of England pound that I am not alone. Using proper techniques, rigorously, does make the initial construction of a project a bit more complex, a bit more laborious. It’s (and you know this bit as well) when you come back to it in six months and you have to walk through the HTML fixing it to add new functions that you’ll think: I wish I did this properly the first time around.

That is, of course, unless you are all paragons of programming and I’m the only one who isn’t. Shiny Bank of England pound available for anyone who proves that that’s the case.

So, read Bobby’s article, pick up any tips you don’t already know, and then (and this is the important bit) apply that knowledge all the time. We’re all about to start playing a great new game, where things work and we can use Ajax techniques to speed up sites and browser manufacturers are working with us to find what we want and web services are out there just waiting to be integrated. Make it your mantra for today that you’ll do things The Right Way. Go on. For me. And for everyone else.

Stuart Langridge and Tony Steidler-DennisonStuart Langridge and Tony Steidler-Dennison
View Author

Stuart Langridge has been a Linux user since 1997, and is quite possibly the only person in the world to have a BSc in Computer Science and Philosophy. He’s also one-quarter of the team at LugRadio, the world's premiere Free and Open Source Software radio show. Tony Steidler-Dennison is a Systems Engineer with Rockwell Collins, Inc., designing avionics and cabin data servers for commercial airliners. He’s also the host of The Roadhouse Podcast, "the finest blues you've never heard."

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week