I have a big content slideshow kinda page that I’m making that is starting to use a lot of event triggers. Also about half of them use the livequery plugin.
Will I see speed increases by unloading these events between slides so only the active slide has bound events?
Also is the native livequery significantly faster then the livequery plugin?(cause it’s certainly less functional)
Also would something like this: http://dev.jquery.com/attachment/ticket/2698/unload.js
unbind livequery events as well?
I really just need to know how long it takes to unload/load an event listener vs how many cycles they are really eating up if I leave them running. Also any information on live events would be awesome.
If by ‘native
liveQuery‘ you meanlive(), then yes,live()is significantly faster thanliveQuery(). The latter usessetIntervalto periodically query the entire document tree for new elements while the former uses event delegation.Event delegation wins handsdown. In a nutshell,
live()will have one handler on thedocumentper event type registered (eg,click), no matter how many selectors you calllive()with.As for your other question, it sounds like you are binding to each slide’s elements and want to know if unbinding and binding again is performant? I would say WRT memory, yes. WRT CPU cycles, no.
To be clear, with the
liveQuery()approach CPU will never sleep.