DOM2 (addEventListener
) handlers are called in the order in which they were registered. So as long as you register yours first, it will be called first, and you can prevent others from being called by using stopPropagation
and stopImmediatePropagation
.
The above is in relation to the specific element, however. If your handler is on a container element and there's an element inside that container with a handler directly attached to it, then all of the handlers for that inner element are called before yours on the container element (this is for bubbling; there's another phase called capture where it's the other way around, but almost no one uses it). [See the old DOM3 events spec (but it's still valid).]
So for what you're describing, it sounds like you have your handler on a container element, and the library has its handler on an element inside that container. To get in front of that handler, you'd have to register yours on that specific element first, before that lib does.