timeago.js is a lightweight JavaScript library that formats dates as relative time strings in the "time ago" format.
The library solves the problem of displaying human-readable relative timestamps, such as "3 hours ago" or "in 2 days", without requiring heavy dependencies. It works by accepting a date input—whether as a Date instance, timestamp, or date string—and converting it to a relative time expression. The tool supports both past and future time expressions and can automatically update DOM elements in real-time as time passes.
The project suits developers building web applications that need compact date formatting without bloat. It works in both Node.js and browser environments and can be loaded via npm or CDN. The library includes built-in support for English and Simplified Chinese locales, with a registration API for adding custom languages. Anyone adopting it should know that the entire library weighs less than 2 kilobytes, making it suitable for performance-sensitive applications. The tool originated as a rewrite of an older jQuery-dependent project, removing that dependency entirely.
The project maintains a well-tested codebase with test coverage for locale implementations. Development activity shows ongoing engagement with locale translations, as the maintainers actively encourage community contributions for additional language support through both issues and pull requests. The project accepts contributions for expanding the locale library and requires that new translations be tested before acceptance.