Wednesday, April 25th, 2007

Seven JavaScript Techniques You Should Be Using Today

Category: Articles

Dustin Diaz has written an article on the Seven JavaScript Techniques You Should Be Using Today.

Dustin delves into:

  • Branch when possible: When performance matters, it’s often advisable to branch out your functions in a way that ensures processor-intensive or memory-hungry tasks won’t be frequently repeated. One of the most common scenarios where this situation can arise is handling browser differences
  • Make Flags: var w3 = !!(document.getElementById && document.createElement); The not operators (!!) simply perform a Boolean conversion. The first operator changes the type of the object on the right to a Boolean, and then the second will just reverse whatever the first returned
  • Make bridges: function getUserNameByIdBridge (e) { getUserNameById(; }
  • Try Event Delegation: Read Christian Heilmann’s work
  • Include methods with your getElementsByWhatever: Use callbacks. getElementsBySelector(‘#example p a’, function(el) {}
  • Encapsulate your code: (function() { ..... })();

Posted by Dion Almaer at 6:37 am

3.1 rating from 40 votes


Comments feed TrackBack URI

6 != 7 :)

Good stuff though.

Comment by Kalle — April 25, 2007

I guess re-inventing the wheel doesn’t get a look in on this website ;)

Comment by Jake — April 25, 2007

Leave a comment

You must be logged in to post a comment.