Having a large number of DOM nodes should not be a big problem (if the client does not have enough RAM); however, manipulating a large number of DOM nodes will be rather slow. For example, looping through a group of elements and changing the background color of each, itβs good if you do this for 100 elements, but it may take some time if you do this for 100,000 elements. In addition, some older browsers have problems working with a huge DOM tree - for example, scrolling through a table with hundreds of thousands of rows can be unacceptably slow.
A good solution for this is to buffer the view. In fact, you only show the elements that are visible on the screen at any time, and when the user scrolls, you delete the hidden elements and display those that are expanded. Thus, the number of DOM nodes in the tree is relatively constant, but you will not lose anything.
Another similar solution is to impose a limit on the number of messages displayed at any given time. Thus, all messages, say 100, will be deleted, and to see them you need to click on the button or link that shows more. This is what Facebook does with its profiles if you need a link.
Sasha chedygov
source share