We have a web application that needs to display messages from the server on the page in some order. The messages can be downloaded all at once with JavaScript, but they should only be shown at their scheduled times. For example, if there are three messages:
[
{ "content": "foo", "offset": 1 },
{ "content": "bar", "offset": 2 },
{ "content": "poi", "offset": 3 }
]
They should appear on the page at 1s, 2s, and 3s from the moment the page is loaded, and each of them should disappear (independently of the others) from the page after it is animated on the page in some way.
My questions are:
Is it better to use JavaScript to dynamically add/remove the message elements to/from the page when it's time, or to add all messages to the page at once (hidden at first) and use the CSS animation delay to control their appearance? There might be a lot of messages (like 10000).
For whichever you think is the appropriate way (CSS/JavaScript), can you give some advice as for how to implement it? I'm a backend developer, so I'm not really sure what to do. Some directions or ideas are appreciated.