Dynamic creation of large html table in javascript performance

前端 未结 7 1335
轻奢々
轻奢々 2020-12-02 23:30

I have an application which is used for data analysis and I\'m having a few performance issues with the creation of the table. The data is extracted from documents and it is

7条回答
  •  抹茶落季
    2020-12-03 00:05

    The way you are building your string will cause massive amounts of garbage collection.

    As the string gets longer and longer the javascript engine has to keep allocating larger buffers and discarding the old ones. Eventually it will not be able to allocate sufficient memory without recycling the remains of all the old strings.

    This problem gets worse as the string grows longer.

    Instead try adding new elements to the DOM one at a time using the jQuery manipulation API

    Also consider only rendering what is visible and implement your own scrolling.

提交回复
热议问题