tags:

views:

260

answers:

4

Is the jQuery live method using setInterval to update the events?

Does this affect performance?

A: 

It seems it does NOT use SetInterval. I could be wrong.

dotty
+7  A: 

Based on this blog as a resource, it appears that jQuery.live() works by attaching the events to the document. Then, when an event is triggered (such as by a click), the event bubbles up to the document level - at which point it is compared against all the live event handlers. If it matches a live event handler, it fires the event for it.

Matt
A: 

I cannot tell you about how it effects performance, but JQuery uses setInterval and setTimeout only when referencing onreadystatechange, which is directly related to its ajax calls and testing to see if the response has yet occurred.

Christopher W. Allen-Poole
+2  A: 

This blog describes pretty well what's going on behind the scene.

http://www.neeraj.name/blog/articles/882-how-live-method-works-in-jquery-why-it-does-not-work-in-some-cases-when-to-use-livequery

live does not use setinterval but livequery does.

Roger
+1 for pointing to a great overview of live vs. livequery (with an introduction to event bubbling.)
Sean Vieira