Open Bug 305289 Opened 19 years ago Updated 2 years ago

Consider not firing image error/load events if no one is listening

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
Linux
defect

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: helpwanted, perf)

The profile in bug 304683 shows us spending about 5% of that pageload firing onload events for the images. There's really no reason to do that if no one is listening, and I propose that we stop doing it. Sort of like we treat mutation events.
Keywords: helpwanted, perf
I've been thinking to do this for all events (after rewrite), though yet quite sure how. Perhaps in PreHandleEvent add a flag which tells whether the event needs default handling; if not, check whether there are any event listeners, and if there aren't, no need to dispatch. Or something like that. Have to just make sure that all these checks don't make the event dispatching slower.
Note that image onload fires async... and a lot of the effort spent is posting the PLEvent, etc. That is, checking in PreHandleEvent may help here some, but not really "enough".
ah, true. Hmm, but I guess there should be a generic way to check whether there are event listeners for some specific event. And that check should handle also anonymous content properly (that is something the mutation events dispatching doesn't handle , I think).
(In reply to comment #3) > And that check should handle also anonymous > content properly (that is something the mutation events dispatching doesn't > handle , I think). > Actually that depends also how we want to implement XBL1 (or XBL2). XBL1 "The action taken (retarget vs. stop) is specific to the event type. In general, UI events are retargeted and mutation events are stopped. Exceptions to the rule are noted below." However currently we don't stop mutation events, but when checking whether there are listeners for them, anonymous content is not used. blaa blaa, I should open a new bug for all this ;)
Having a generic way to check that's not to slow would be sweet.
Assignee: general → nobody
QA Contact: ian → general
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.