Fastest way to add/remove multiple elements in DOM

前端 未结 2 541
-上瘾入骨i
-上瘾入骨i 2021-01-13 00:21

Edit: It\'s not a duplicate of \"Fastest DOM insertion\" because it includes the event listeners variable too. Anyway I will edit the question.

I wo

相关标签:
2条回答
  • 2021-01-13 00:49

    Google/SO are your friends:

    For example for question 1/2 , see Fastest DOM insertion

    I think, you can search for a lot of them.

    Another good place to search for performance comparison beside google/SO is to use jsperf: http://jsperf.com/browse and http://jsperf.com/popular. I'm pretty sure there are response to a lot of your question there. And if you have some questions that are unanswered, you can test them as well in the main page http://jsperf.com/.

    0 讨论(0)
  • 2021-01-13 01:02

    1   Set the value of innerHTML on the parent element to a string containing HTML for the new elements.
    2   Same as 1.
    4   Set the value of innerHTML on the parent element to an empty string.
    7.1   Call Node.removeChild(), save the returned Node object, and then pass the node to Node.appendChild().

    0 讨论(0)
提交回复
热议问题