Splitting icon indicating copy to clipboard operation
Splitting copied to clipboard

Checking performance

Open shshaw opened this issue 7 years ago • 1 comments

Ensure that the text population is being done in the most perfomant way:

https://twitter.com/_developit/status/997132016612270081

shshaw avatar May 22 '18 19:05 shshaw

Main consideration is DOM thrashing.

Also, may want to consider this rewrite, specifically around line 115: https://codepen.io/shshaw/pen/c43eea9b820949a0e3c2bda779bd0b89

    // Remove element from DOM to prevent unnecessary thrashing.
    var parent = el.parentNode;
    if (parent) {
      var temp = document.createTextNode("");
      parent.replaceChild(temp, el);
    }

then after the span creation:

    // Put the element back into the DOM
    if (parent) {
      parent.replaceChild(el, temp);
    }

shshaw avatar Jul 03 '18 15:07 shshaw