Event propagation horribly slow?
Hi!
I've run into a problem. I'm working on a plotting plugin with
interactive features like zooming. So I need to know what the user is
doing with the mouse. But the event stuff for mousemove is really
slow. Basically, if you bind an empty function like this:
function cb(e) {}
#("#somediv").mousemove(cb);
I can get Firefox to use up 100% CPU on my trusty old 950 Mhz Pentium
III by moving the mouse around on the div. I'd really like to spend a
couple of those precious CPU cycles executing my callback...
As far as I can tell almost all the time is spent in the fix function,
right here:
// store a copy of the original event object
// and clone to set read-only properties
var originalEvent = event;
event = jQuery.extend({}, originalEvent);
Apparently extend() is slow at copying all the junk in originalEvent
over. According to the Firebug profiler, 92% of the time is spent in
that extend() call. It takes between 12-24 ms on my machine, the rest
of the code in that function takes 0-1 ms.
I'm really not sure how to fix this, any suggestions?