JavaScript Perfromance Tip- Don’t Test Against obj.length. Test Against a Local Variable.

I saw it yesterday in some code I was debugging and I realized I’ve become hyper sensitive to this common pattern: var anchors = document.getElementsByTagName(‘a’); if (anchors.length > 0){ for (var i=0; i < anchors.length; i++) { addEvent( anchors[i], 'click', trackLinks ); }; }; Why am I sensitive to it? Well, what are some of […]

JavaScript Library Showdown. Video of my CDIA Presentation is Live. Check It Out!

Thanks to Jason Duclos, my presentation from a couple of weeks ago is live. In it I compare standard JavaScript DOM methods to YUI, jQuery, Dojo and Prototype/Scriptaculous. JavaScript Library Showdown from rob larsen on Vimeo. Here’s the deck. Jason is the man for putting this together, by the way.

Presentation Done. Thanks to all Who Attended.

My presentation went well, I think. It started a little later than I would have liked, and I didn’t have any water (insane? yes.) but overall it was a lot of fun. People seemed interested, which is the important part. The really interesting news is that the presentation was recorded, so I should be able […]

getElementsByTagNameNS. Now I Know. And Knowing is Half the Battle.

Yesterday I was wondering why obj.getElementsByTagName wasn’t working in Safari/WebKit on a tag with a namespace prefix. I wondered, aloud, whether or not it was just something I was ignorant of. It turns out that was the case. Dom Level 2 added new namespace specific methods to search through documents or document fragments for tags […]

getElementsByTagName Namespace Prefix Strangeness in Safari/Chrome/WebKit

Is It Me or the Browser? I had a Safari bug on a project I’m rushing to get out the door. We’re using a Flickr feed to populate a div with link+thumbnail to some flickr images. In Firefox/Internet Explorer I simply did the following to build the links: flickr : function(obj) { //get the full […]