jquery-timeago icon indicating copy to clipboard operation
jquery-timeago copied to clipboard

Make each timeout interval depend on the timestamp itself

Open mitar opened this issue 10 years ago • 1 comments

Currently this plugin creates many timeout intervals, but all of them work at exactly the same period. This is suboptimal. Much better would be that depending on the current timestamp a next update interval would be computed. For example, if it is displayed "1 hour ago" you know that for next hour you do not have to update at all. So you can create a timeout which will be called in an hour. I think this is much better than having one global timeout which goes all around and checks everything again and again (what others are proposing). It is much better to have timeouts for each timestamp, but just not call them with static period. Timeouts are effective then and it is left to the browser to call them when needed. The solution is just to tell the browser when exactly this will be.

I implemented something like this in the past and it worked great.

mitar avatar Apr 21 '14 21:04 mitar

This is a reasonable suggestion, and I agree that the suggestions from others for a global timeout isn't a huge performance improvement, but there are some potentially nice side effects and some elegance in simplicity of using a global timeout. This probably isn't something that I'll look into until a Timeago 2 rewrite happens (it's in my head, but not planned anytime soon).

rmm5t avatar Dec 24 '14 05:12 rmm5t