Saturday, 3 June 2017

Is it a smart idea to use setInterval to update a time frequently?

How much of an impact on the server would there be if I used a setInterval like this to continue changing the time displayed in the browser every 10 seconds for example:

setInterval(function(){
  var time = moment($('#bidTime').val());
  $('#ago').text(time.fromNow());
  $('#ago2').text(time.fromNow());
}, 10000);

On the dashboard of my web app, I have a "Last Updated" column with a displayed time that I want to display "xx seconds ago" etc..

Is it bad to use setInterval in this case? Is there a better way?



via kolbykskk

No comments:

Post a Comment