JQuery mousemove performance

When I bind the mousemove event to an element, it works smoothly with every browser except Internet Explorer. In IE, CPU usage is too much and some related things (like tooltip) are ugly. Is there a way to get rid of the performance issue? (yes I know don't use IE :))

UPDATE: Even if I don't do anything in the event handler function, the CPU usage is still high. Here's my code:

$("#container").live("mousemove", function(e){

});

      

This is normal?

+2


a source to share


2 answers


Are you using jquery selector on mousemove event? I've seen cases where jquery selectors get slower on complex pages, if you put a selector on an event that fires many times there is a noticeable lag. In many cases you can just keep the jquery reference to the element until mousemove, then mousemove uses the reference to the element instead of reusing the selector that internally iterates over the DOM every time it is called.



+2


a source


You should have no problem binding simple updates to your mouse move event, even in IE. Drag and drop, as seen recently on gazillion sites, is implemented this way.



If you see massive spikes in the CPU, I would think there is probably a big reason.

0


a source







All Articles