Splitting
Splitting copied to clipboard
Checking performance
Ensure that the text population is being done in the most perfomant way:
https://twitter.com/_developit/status/997132016612270081
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);
}