Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Only use a single timer/setInterval #96

Soviut opened this Issue · 5 comments

3 participants


It would seem to make sense that a single "global" timer could be used on a page rather than an individual timer per element. The reference to the timer could be stored in the $.data() of the document element so that it can be referred to and cancelled. This timer could then be subscribed to by any elements that need updating or trigger 'timeago_update' that could bubble up from the document.


I think that's a good design change. Timeago is due for a small rewrite to accommodate suggestions like this and to accommodate other often requested features.


I wouldn't mind trying to help with that. Especially if we can adapt it to CoffeeScript as a pre-processing step.


There is an problem with this : if, for example, there is a single 1-second element, and a thousand 1-month elements, using a single timer will trigger the event for every 1-month element at each second.

I think we should have a timer for each duration (1 second, 1 minute, 1 hour, 1 day, 1 week, 1 month, 1 year), each one having its own list of elements.


Not a bad idea. However, I assumed an object could do the same thing. Simply use second intervals as keys. I'm not sure which would be more efficient, but it would potentially keep the logic more centralized than several disparate timers.

var intervals = {
    1: [ ... ],
    60: [ ... ],
    3600: [ ... ],
@mweibel mweibel referenced this issue from a commit in mila-labs/jquery-timeago
Michael Weibel Implemented only one Interval on a page.
This commit will fix jquery.timeago's issue to have an interval
for each timeago element on a page.
By doing this it also removes destroyed elements automatically.

As such, this commit fixes rmm5t/jquery-timeago#96 and

Closing this out in favor of discussions on #90 and #122.

@rmm5t rmm5t closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.