Bug Tracker

Opened 15 years ago

Closed 14 years ago

Last modified 13 years ago

#4398 closed bug (wontfix)

mousemove() event handling is slow

Reported by: olau Owned by: brandon
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc: olau, flesler
Blocked by: Blocking:

Description

Event handling for mousemove event still causes a significant overhead. If I attach to document.onmousemove with an empty anonymous function and wiggle the mouse on my trusty old 950 MHz PIII, Firefox 3 is using about 22% CPU. With jQuery's mousemove() and the same empty function it's about 45-50%.

Here's a breakdown of the timings from the Firebug profiler with jquery-1.3.2.js:

name   calls      %    owntime       time
fix()    668 71.78% 2538.725ms 2806.368ms (line 2713)
handle() 668 13.84%  489.503ms 3356.589ms (line 2666)
Event() 1336  5.73%  202.810ms  267.643ms (line 2800)
(?)()    668  5.09%  180.029ms 3536.618ms (line 2465)

fix() still appears to be the culprit. I think a solution might be to special-case mousemove (because we get a lot of those), as far as I can tell most of the stuff jQuery is doing on each and every of those events is completely useless for mousemoves where you typically (?) just want the pageX/pageY.

Change History (3)

comment:1 Changed 15 years ago by flesler

Cc: olau flesler added
Component: unfilledevent
Owner: set to brandon

We can't make an exception for mousemove, that's completely confusing and would make our API a bad one.

I think the exception should be done on your side if needed.

comment:2 Changed 14 years ago by brandon

Resolution: wontfix
Status: newclosed

comment:3 Changed 13 years ago by katspaugh

The overhead is known to be caused by the page reflow when getting the "scrollTop"/"scrollLeft" (see http://dev.jquery.com/ticket/6942).

The API could provide a way to set the values of scroll and client position externally.

In such case, one could cache scroll and client position values on events that cause the change of these values and transfer them to jQuery.

Currently, the "fix" method can not even be overridden externally.

Note: See TracTickets for help on using tickets.