top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What are the speed differences between jQuery hide()/show() and addClass()/removeClass()?

+1 vote
435 views
What are the speed differences between jQuery hide()/show() and addClass()/removeClass()?
posted Jul 17, 2014 by Amarvansh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

There is not more speed difference between hide()/show vs addclass()/removeclass.But in performance wise instead of jquery hide()/show() that addclass()/removeclass will be better.

Also,Using hide()/show() would arguably be faster to implement since it requires writing less code.

Example

// 100000 iterations

$("p").hide()/$("p").show(): 6136ms

$("p").css({display:"none"})/$("p").css({display:""}): 4617ms


// cached: $p =  $("p")

$p.hide()/$p.show(): 4056ms

$p.css({display:"none"})/$p.css({display:""}): 2745ms

Credit : http://www.quora.com/What-are-the-speed-differences-between-jQuery-hide-show-and-addClass-removeClass

answer Aug 13, 2014 by Ujjwal Mehra
Similar Questions
0 votes

I want to add a menu to my application screens. The menu will have the menu icons which are horizontal scroll-able one menu at a time when left or right arrow pressed.

+1 vote

Am confused with these functions.Can any one tell me the difference and give some example for each .

0 votes

Also,tell me what are the types of framework are there ?

...