Opened 12 years ago
Closed 11 years ago
#2298 closed bug (duplicate)
global ajax events can be slow if lots of DOM elements
Reported by: | davidserduke | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | ajax | Version: | 1.2.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If there are lots of DOM elements, the global ajax events can be very slow. See related topic:
http://groups.google.com/group/jquery-dev/browse_thread/thread/d189549ea277e7e6
I was thinking it might make sense to allow the coder to override the "global" nature of the ajax events by passing in a selector. Perhaps something like this:
$.ajaxSetup({ global:".global_event_elem" });
So instead of sending the global events to all elements it would just go to those specific ones in the selector.
I put together a possible patch that is completely untested.
Attachments (1)
Change History (8)
Changed 12 years ago by
comment:1 Changed 12 years ago by
Component: | core → ajax |
---|
comment:2 Changed 12 years ago by
I think this can only be solved by improving global event triggering, or disabling it... My app got stuck for 40 seconds everytime I used $.ajax, because of these events.
comment:3 Changed 12 years ago by
Milestone: | 1.2.3 → 1.2.4 |
---|
What did you think about the patch I created? Did you try it out? Of course, as I said, it is untested but the theory seems sound. It would allow "global" triggering to be specific to an expression. I'd think that would be sufficient for a large dom.
comment:4 Changed 12 years ago by
IMO, we need to go backwards a bit, and keep an array of dom elements, for each event. So global triggering will be fast and focused. Those arrays can always be nullified on window.unload along with the global unbind that we now have. I don't want to be... negative, but I think that global triggering, like this, is completely useless and I personally evade it.
comment:5 Changed 12 years ago by
Did you look at the patch? Why do you think it would be slow? Since you could put any selector in there you could even do something like
$.ajaxSetup({ global:"#globalajaxwatcher" });
I might be missing something but I don't follow your logic. Even if the DOM had thousands of elements I'd think that would be very fast.
comment:6 Changed 12 years ago by
Ah, didn't understand it before. This approach forces the user to maintain a selector that matches all the dom elements that have ajax events bound, this already seems to go in the wrong direction.
IMO, if we're already storing dom elements (can leak) in the handlers (.elem), then keeping an array(or map) for each event seems to me like the best approach.
Also bear in mind, that this applies to any global triggering, not just ajax events.
comment:7 Changed 11 years ago by
Milestone: | 1.2.4 → 1.3 |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
#3107 improves this situation quite a bit.
untested patch (for the idea)