Live data from Hacker News

Smart Time Ago: a new JS lib to update relative timestamps more efficiently

blog.pragmatic.ly

11–14 of 14 posts

Re: Smart Time Ago: a new JS lib to update relative timestamps more efficiently

#12

I just use http://momentjs.com/ Does timeago (with localizations) and more in one tiny library.

It's different. While momentjs focus on date parsing, manipulating and formatting, smart-time-ago is the lib to update the relative timestamps in time on the page.

Re: Smart Time Ago: a new JS lib to update relative timestamps more efficiently

#13

I just use http://momentjs.com/ Does timeago (with localizations) and more in one tiny library.

It's different. While momentjs focus on date parsing, manipulating and formatting, smart-time-ago is the lib to update the relative timestamps in time on the page.

Moment does both functions and 99% of the time that you're working with dates in an app, you're going to need both. Also, Moment is localized and has a fairly large community around it. The world doesn't need yet another timeago.

Re: Smart Time Ago: a new JS lib to update relative timestamps more efficiently

#14
post #6

This is such a minor tweak that I can't see how it's worth trouble of downloading even a byte of extra code to get it done. Please correct me if I'm wrong. Edit: "minor tweak" in terms of efficiency. The processing power saved by making it "smart" is probably less than what it takes to download the extra code.

It depends on the application itself. For pages which user will only stay for few minutes, no much more efficiency gained. But for realtime apps which user will keep the page open for hours/days, it will improve a lot. And for apps which have more read than write, it will also improve a lot. BTW, I'm not sure whether I catch you about the "extra code". It's a replacement with less than 1KB difference in size.

Even 1kb seems like too much. The processing power to handle the time ago logic is so small, having to download 1kb of data more probably takes more processing power than you're saving.
Post reply on HN