Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine number of times the DOM was manipulated/appended

Is there a way to count the amount of times that the DOM has been appended to?

like image 667
West55 Avatar asked Feb 21 '23 03:02

West55


1 Answers

If you're stricly after .append(), you can just patch it, like:

var _origAppend = $.fn.append;
$.appendCount = 0;

$.fn.append = function() {
    $.appendCount++;
    return _origAppend.apply(this, arguments);
};

Now, you could just access $.appendCount at anytime to see how often it was called. However, be aware that there are lots of functions which can manipulate the DOM. It might be a more clever idea, to patch jQuery.fn.domManip instead. That method is called internally basically at any dom manipulation (like you might have suspected because of the name)

like image 84
jAndy Avatar answered Mar 08 '23 23:03

jAndy