开发者

Does performance of an event handler depends on the number of child elements

I've got a single mousedown event handler on a table with dynamically increasing number of rows (right now over thousand, in perspective should have been unlimited) and I observe a drop down in performance as the number of preloaded rows increases. The purpose of event handler is simple - figure out which row was clicked and highlight it.

I do not know exactly what causes the slowdown and I'm not sure if it's event handler. I just wonder if number of child elements that could trigger mousedown bubble c开发者_如何学Goan affect the performance of an event handler attached to single parent element?

Update: I came up with simple example here: http://client.infinity-8.me/table.php?num=1000 (you can pass whatever number you want to num), basically it renders a table with num rows and has a single event handler attached to a parent table. I should conclude from this, that there actually is no noticeable dropdown in performance, caused by number of child elements.


In theory it shouldn't. Only deepness should matter, since bubbling goes up by checking handlers on every level (one per level).

It performs great with 10 000 elements even on IE6.

See it in action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜