Re: Handy stuffz (lest we forget)
Reply #6 –
I knew that the hide function was quite a bit slower than native, but cool find on using the css approach.
I believe the main reason that .hide() is slower is that it has to save what the display attribute was before, so that .show() can restore it (assuming you need that). So to do that it uses the .data() method for storing the display information on the DOM. Which is a fancy way of saying .hide() loops through every element twice: once to save then once to update it to none.
Like anything with Jquery, need to make sure you need the functionality / capability that the library offers for a particular task, otherwise it can be a bit of overhead.
Re: Handy stuffz (lest we forget)
Reply #7 –
Makes sense. So since it's basically just an off switch that sets display: none; anyway the css approach is going to be better.
I agree about the overhead, but a long as we're sensible about how we use it I think it's worthwhile. To my mind, the big advantage with jQ is that it works across browsers without any screwing around. They've already done that bit (yay!).