Skip to content Skip to sidebar Skip to footer

Read And Replace Text In Html Causes High Cpu Load

I have a problem with high CPU load on a website where I want to replace some text with links. The script is loaded at the end of body. This works normally when there are no videos

Solution 1:

As @criz already mentioned, building DOM in a loop is a very bad practice. It's much better to create documentFragment and attach it to the DOM. Take a look at the https://developer.mozilla.org/en-US/docs/Web/API/Document/createDocumentFragment There is an example.


Post a Comment for "Read And Replace Text In Html Causes High Cpu Load"