Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Clean up our own setInterval calls #92

wants to merge 1 commit into


None yet
1 participant

If you use timeago within an app that destroys the timeago-managed divs, you can fairly quickly add LOTS of timers, which slows down the page.

This patch cleans up the setInterval calls by doing two things on update:

  1. Check if the timer-ed element is in the page. If it isn't, don't update it.
  2. Check if every element that we're responsible for updating is not in the page. If none are, kill our timer.

This patch will cause issues with users of timeago that need to update elements that haven't been inserted into the page. I can't think of a reason why you'd want to do that, but something to be aware of nonetheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment