Changes between Initial Version and Version 1 of Ticket #9546, comment 8


Ignore:
Timestamp:
Sep 12, 2013, 3:58:44 AM (7 years ago)
Author:
frederik.elvhage
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9546, comment 8

    initial v1  
    1 Update: there was a misunderstanding in the original bug-description. [[BR]]
     1I believe that cleaning up dom on removal is a general concept (to avoid memory leaks aso) so there should be a possiblity to register with the framework for cleanup/remove. So jQuery should offer a callback or something. [[BR]]
    22
    3 The (jQuery-UI) cleanData-Proxy is used to implement the (still needed) jQuery-UI remove-Method. [[BR]]
    4 The actual problem is, that triggering remove on every element in the dom is expensive.
     3In this particular case such a callback would save the extra iteration through all elements.
    54
    6 This is browser independent but will hit you harder in IE.
     5Doing some further testing i found that the iteration is cheap. The triggerHandler('remove') is whats expensive regardless of attached handlers. The solution would be to trigger the remove-handler soley on elements with widgets attached.
    76
    8 Replying to [ticket:9546 frederik.elvhage]:
    9 > The (jQuery-UI) cleanData-Proxy i find in my jquery-ui-1.10.1.custom.js slows down ajax-calls (especially) in internet explorer 8.
    10 >
    11 > I have found that removing this proxy will reduce ajax-processing time by more than 60% in IE8 and on large ajax-calls (~3.3s -> 1.1s).
    12 >
    13 > It is obviously a counter-measure for a jquery-bug that has been fixed in 1.6.3.
    14 > {{{
    15 > $.cleanData = function( elems ) {
    16 >       for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
    17 >               try {
    18 >                       $( elem ).triggerHandler( "remove" );
    19 >               // http://bugs.jquery.com/ticket/8235
    20 >               } catch( e ) {}
    21 >       }
    22 >       _cleanData( elems );
    23 > };
    24 > }}}
    25 >
    26 > I suggest removing this proxy and change legacy-support to 1.6.3+ (instead of 1.6+).
     7I.e. the widget could set a flag on initialization and check it in the cleanData-Method.
     8
     9I have made another fiddle that allows testing of different cleanData-Implementations here:
     10[http://jsfiddle.net/felvhage/r7buw/ jsfiddle/cleanData][[BR]]
     11
     12My first naive implementation will test for the existance of events before it calls the remove-handler.
     13This already saves at least 90% of the overhead. I will look further into this in time an provide a pull request.
     14
     15