I am analyzing some performance issues at a website and ran into a piece of code in superfish where i was wondering if this could be optimized. in the superfish method i can see the following code snippet:
var $a = $('a',this); $a.each(function(i){ var $li = $a.eq(i).parents('li'); $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call ($li);}); }); I used the dynaTrace AJAX Edition to analyze the performance of the superfish method. It turns out the the .eq(i) on $a takes about 20% of the total execution time. As we are in the each method - wouldnt it be better to just use this instead of accessing the current object in the each loop via the eq method? Couldn't the above code be changed to var $a = $('a',this); $a.each(function(i){ var $li = this.parents('li'); this.focus(function(){over.call($li);}).blur(function(){out.call ($li);}); }); Thoughts?