why does replacing InnerHTML with innerText causes >15X drop in performance

后端 未结 2 1936
一向
一向 2021-01-11 20:44

this question arises from my previous post why a tiny reordering of DOM Read/Write operations causes a huge performance difference .

consider the following code:

2条回答
  •  一个人的身影
    2021-01-11 21:38

    The difference almost certainly comes from the extra effort it takes to get the InnerText (which I believe removes extraneous tags and just returns the text within an element). InnerHTML on the other hand simply returns data that has already been parsed and understood by the browser.

提交回复
热议问题