title: How do you force your Javascript event to run first, regardless of the order in which the events were added?
body: <p>I have Javascript that people are including in their page.  In my Javascript I have a version of jQuery (1.8 for sake of easy reference) that is sectioned off into its own namespace, and referenced via a global variable (but not one of the two default vars of &quot;$&quot; or &quot;jQuery&quot;).  This allows users to have jQuery in their page and have it not interfere with the stuff I'm doing internally in my functions.</p>
  <p>So we have one page that has jQuery already (1.4), and everything works fine, except that the user and my code are both listening to &quot;click&quot; events on elements, and theirs is going first, so on the few events they do that return false, jQuery stops propagation and my event never gets triggered.  I need my event to go first.  The user is expecting my <code>onClick</code> functionality to still work.</p>
  <p>Now I know that jQuery keeps its own order of events internally through the <code>_data()</code> object, and through this it is possible to unbind existing events, bind my event, then rebind the existing events, but that only applies to objects bound through that instance of jQuery.  I'd rather not just blindly look for the jQuery object in hopes that the conflict was introduced by a user's own version of jQuery.  After all what happens when a user binds the event not through jQuery?  Trying to manipulate the existing jQuery object in the page isn't a good solution.</p>
  <p>I know that, depending on browser, they are using <code>addEventListener</code>/<code>removeEventListener</code> or <code>attachEvent</code>/<code>detachEvent</code>.  If only I could get a listing of the already added events, I could rebind them in the order I wanted, but I can't find out how.  Looking through the DOM via Chrome inspect I don't see <code>onclick</code> bound anywhere (not on the object, not on window or document either).</p>
  <p>I'm having the darndest time trying to figure out just exactly where jQuery binds its listening.  To be able to control the order of its own events, jQuery must blanketly listen somewhere and then fire off its own functions right?  If I could figure out where that's done I might get some insight into how to ensure my event is always first.  Or maybe there's some Javascript API I haven't been able to find on Google.</p>
  <p>Any suggestions?</p>