Are Jquery Fadein(), Animation() Functions Non-blocking?
I have a page which issues several ajax queries in $('document').ready(). I want to use fadeIn() or animation() to display some information for a few seconds after received the fir
Solution 1:
Yes, they are non-blocking. The animation methods just initiate the animation and returns immediately.
Any code that updates the user interface has to be non-blocking, as the user interface isn't updated while any function is running.
Solution 2:
All javascript can be considered blocking because it is entirely single threaded.
You can't do something like:
fadeIn
sleep(5 seconds)
fadeOut
without causing incoming ajax responses to be queued until the fadeOut
has returned. Using setTimeout is probably the best thing to do.
EDIT: As @Guffa pointed out, the actual calls to fadeIn
and fadeOut
are not, themselves, blocking calls. What you probably want is something like:
fadeIn(time, function() {
setTimeout("fadeOut()", 5000);
});
or words to that effect.
Post a Comment for "Are Jquery Fadein(), Animation() Functions Non-blocking?"