I was just reading this: http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx
And had some questions about some of the advocated tricks:
9 - Give your selectors a context:
What's the difference between using a context and using a more specific selector?
Rather than doing
var selectedItem = $('#listItem' + i, $('.myList'));
What about
var selectedItem = $('.myList>#listItem' + i);
Which one is faster/better, or is there no difference?
12 - Learn about event delegation:
I would imagine that at low handler counts event delegation is slower than normal binding.
How many handlers is the time when you should start using event delegation?
Also, what is the difference (in terms of how fast or how 'good' it is) between using delegation and creating a click target in dom, having the user click that click target, and then have the click target find the elements to manipulate. Is this method faster or is delegation faster?
Edit: In addition, how many levels should you be delegating? Is it better to delegate something 10 levels away, or to simply bind 2 handlers.
13 - Use classes to store state
14 - Even better, use jQuery's internal data() method to store state:
Why use data vs classes? Is data faster? I think I generally find classes to be easier to read, contradicting what it says in the blog entry, because I can see it in the DOM.
Thanks!