Skip to content
Advertisement

Which events are the most intensive?

Which events are the most resource intensive to have attached? Is a mouseover “worst” than a click? Are there any events that are known to be really harsh on the browser? I have my sights on IE7 mainly, as we are seeing performance issues there. We use event delegation where we can.

Or, how can I profile events which are actually running to determine which have the greatest impact on performance at runtime?

I’m interested in the events themselves, please don’t tell me I need to go look into what my functions are doing in those events. Problems may exist there, but that’s not my question.

Advertisement

Answer

So, to start with, events that fire more often can be more troublesome. So a mouseover event, which fires “continuously” as the mouse moves over an element, could cause a performance impact more easily than a click event, which can only fire as fast as the user can click.

However, it’s the code you put in your handler that will have the real performance impact.

If firing speed is an issue, check out the excellent jQuery throttle/debounce plugin: https://github.com/cowboy/jquery-throttle-debounce

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement