JavaScript Best Practices

February 10, 2012 — Leave a comment

I recently came across two good resources that discuss some best practices when it comes to JavaScript. The first is an article at Developer Drive, titled Top 10 “Must Follow” JavaScript Best Practices, written by Salman Siddiqui (it’s a good enough article that I’ll ignore the dubious use of quotation marks). It’s a pretty good list, with a range of beginner to advanced topics. I would disagree with one, however: “Better to avoid DOM.” While DOM manipulation is expensive, it’s often required, so I think it’s better to acknowledge that this is a necessary evil we’re stuck with and hope that browsers continue to make improvements in this area. I liken it to the common economic theory that getting a loan to buy a car makes poor monetary sense (because it’s a loan on something that depreciates). The fact is most people need a car to work and make money, so a car loan is often necessary. But I digresss…

The second resource is a presentation titled JavaScript “Best Practices” (again, the quotation marks), by Christian Heilmann. Heilmann presents about 20 specific suggestions and then explains them all in detail. The presentation itself lacks pretty much any style whatsoever, but content is more important, no? There’s lots of code in the presentation precisely demonstrating both good and bad behaviors, along with explanations as to why something is problematic.

I’m in the process of writing my own article, titled “The 10 Best JavaScript Development and Design Habits”, to be published at Peachpit.com. I’ll post a link to that when it goes online.

If you enjoyed this post, then please consider following me using your favorite social media, the RSS feed, and/or by subscribing to my newsletter. Or go crazy, and buy one or more of my books . Thanks!

No Comments

Be the first to start the conversation.

Comments are great, but I'd strongly prefer any requests for assistance get made in the support forums. Thanks!