What to do with chat messages that are no longer visible?

  • 0
    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.

    How should you delete the oldest messages?
    JavaScript Savannah Lyons, Feb 19, 2020

  • 3 Answers
  • 0
    Adalaide Gallegos

  • 0
    Hello.

    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

  • 0
    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

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!