Slow JQuery hide and show

Very often it is very important for UIs in web apps to show and hide blocks of content.

However, it turned out that iPad-versions of the same menus work about 1 second longer than desktop versions of the same web app. Real-life variations can be 1 to 3 seconds. In order to improve the menu for iPad, we needed to significantly reduce response time.

In the middle of 2010 at a San Francisco jQuery conference a problem of “High Performance jQuery” has been discussed. So Robert Duffy said that for the performance .hide() and .show() methods turned out to be slower than working directly with CSS properties.

Thus we replaced hide() and show() to css({‘display’: ‘none’}) and css({‘display’: ‘block’}) and voilà. Simple as that!