jQuery appending an array of elements

后端 未结 9 684
星月不相逢
星月不相逢 2020-12-13 23:34

For the purpose of this question lets say we need to append() 1000 objects to the body element.

You could go about it like this:

         


        
9条回答
  •  囚心锁ツ
    2020-12-14 00:10

    If you're going for raw performance then I would suggest pure JS, though some would argue that your development performance is more important than your site's/program performance. Check this link for benchmarks and a showcase of different DOM insertion techniques.

    edit:

    As a curiosity, documentFragment proves to be one of the slowest methods.

提交回复
热议问题