I’m considering using live() to bind an event handler to a function I haven’t inserted into the DOM. However this looks expensive – it must have to do a runtime check any time an element is inserted, or any time a “click” element is performed, for example, to see whether the handler should be called.
Is this something worth worrying about in practice, or is Javascript so fast now that this isn’t worth caring about?
Reference page for the live() function: http://api.jquery.com/live/
No,
.live()uses event bubbling to do its thing. It just attaches to the root element and reacts to events bubbling up through the DOM tree. It does not keep checking DOM elements all the time.From the very page you link to:
Keeping reading there as it goes into more detail.