Hi
I know I'm just being OCD about a few milliseconds worth of performance time, but I was just wondering why the following is true for me. It seems goes against my logic.
I currently have a div that has fades out the image inside on hover:
$('div.someclass').hover(function() {
$(this).children('img').fadeOut(function(){
// do something
});
}, function() {
// do something
});
After some testing, (looping through selectors 1000 times, taking the average of 9 tests) I have used 3 different selectors and concluded that the speed is in this order: 1. $(this).children('img') runs the fastest -avg about 400ms; 2. $('img', this) - avg about 900ms; and 3. $(this).find('img') runs the slowest - avg about 1000ms
This goes against the logic that having two function calls would be slower than one. Plus, I have read that internally, jQuery converts the second case to the third case so would the third case be slower?.
Any thoughts?
P.S. this is my first question here even though I browse this site a lot, awesome resource! =)