mgreenblog

posts by category about this blog

The price of `cloneNode`

So the function fix_dom_clone described in my last post isn't exactly cheap. In fact, it's far and away where my lens library is spending most of its time.

FunctionCallsPercentage of time
fix_dom_clone492047.22%
deep_clone60225.57%
get35135.51%
dom_obj208425.34%

I've implemented a few optimizations to reduce the number of times it needs to be called, but its recursion is brutal. The DOM treeWalker might be more efficient than what I have now. I don't think it can matter much, because according to this website, IE and Safari don't support it.