Side navigation
#2298 closed bug (duplicate)
Opened February 07, 2008 04:55PM UTC
Closed August 08, 2008 03:55AM UTC
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 (7)
Changed February 07, 2008 04:58PM UTC by comment:1
component: | core → ajax |
---|
Changed March 18, 2008 10:27PM UTC by comment:2
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.
Changed March 27, 2008 06:05AM UTC by comment:3
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.
Changed April 01, 2008 03:30AM UTC by comment:4
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.
Changed April 02, 2008 04:27AM UTC by comment:5
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.
Changed April 05, 2008 06:33PM UTC by comment:6
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.