Sean H Jenkins
Sean H Jenkins

Reputation: 1780

JQuery slide doesn't seem to be smooth?

Maybe because my PC is quite old and slow, but JQuery's slide seems to not be very smooth. It's fine if there are not many elements on the page, but becomes sluggish even after embedding one youtube video.

My code is very simple

$('#mainmenu-cats').click(function(){

    $('#main-categories').slideToggle(400, 'swing');

    return false;
});

Is there any way to make JQuery smoother?

Upvotes: 0

Views: 160

Answers (1)

Interrobang
Interrobang

Reputation: 17454

The short answer: jQuery's animations just aren't as smooth as, say, MooTools'. There is nothing wrong with your code, and in some browsers (Firefox is notorious for it) the animation will just be jerky.

One future-looking solution would be to start looking into replacing these animations with CSS Animations. They're hardware-accelerated in many cases and will provide a smoother experience. Then, you can fallback to jQuery animations if the browser doesn't support animation (you can use Modernizr to detect this).

Upvotes: 2

Related Questions