|
|
|
|
|
by Jakob
4526 days ago
|
|
Not sure why you got downvoted. It still is slower than expected. I published a jsperf here with jquery 1.11. http://jsperf.com/jquery-show-hide-vs-css-display-none-block... Show()/hide() is still very expensive because it checks the visibility before setting it. What surprised me though is that $elem.css('display', 'none') is equally slow. That smells like an upcoming pull request. $elem[0].style.display='none' is still the way to go. |
|
Remember, however, that many of your "comparable" test cases are making assumptions that jQuery can't make. For example, .show() sets the display property back to what it was before a previous .hide(), to do that it has to query the display property when hiding. If you try some ideas for fixes, the unit tests should indicate whether you've run afoul of such problems.
Is the performance of .show()/.hide() causing issues? Under what conditions?