views:

408

answers:

2

Hi,

When I bind a mousemove event to an element it is working smoothly with every browser except Internet Explorer. With IE the CPU usage is way too much and some associated things (eg. tooltip) are ugly. Is there any way I could rid of the performance problem? (yeah 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){

});

Is it normal?

A: 

You should have no problems binding simple updates to the mouse move event, even in IE. Drag/drop, as seen in a gazillion websites recently, is implemented exactly this way.

If you're seeing massive spikes in CPU, I'd consider perhaps there's a larger underlying cause.

jvenema
+1  A: 

Are you using jquery selectors in the mousemove event? I have seen cases where the jquery selectors slow down in complex pages, if you put the selector in an event that fires many times, there is noticeable lag. In many cases you can just store the jquery reference to the element before mousemove, then the mousemove uses the element reference instead of again using a selector that internally re-traverses the DOM every time it is called.

David