How to effectively remove namespaced event listeners from ALL DOM elements?
I know I can do it like this: $('*').off('.namespace');
But my feeling is *
not a good idea because jQuery will go through the whole DOM tree and it will be slow.
jQuerys internal $.cache
contains information about event listeners that have been linked through.on()
Is there a way to tell jQuery to just go through that internal cache and remove all event listeners from a specific namespace from any elements - without the need for *
a DOM tree?
Edit: The problem is that I don't know which elements the listeners were attached to - I only know the namespace they were attached to.
source to share