What to do with chat messages that are no longer visible?
In general, I made a chat in which you cannot scroll. But here are the messages that are no longer visible.
in the HTML structure. It seems to me that if unnecessary messages are not deleted, then this will affect performance.
The easiest way to implement messages is through an array. If your approach is exactly this, then you can simply limit the length of the array, for example, when an application receives a new message, it checks the length of the message history and removes the extra ones, depending on the method of adding (array.splice ()).
If the implementation looks different, then attach the code for review.Anonymous
The performance will not be affected if the display of a fixed number of lines will go from the array.
What we don't display is stored in memory.
PS: without scrolling - somehow, crooked ...Theodore Gould
To place the code, please use CodePen or similar tool. Thanks you!