$ account serkanyersen
ifvisible.js is a modern, dependency-free browser library that provides a clean, event-driven API for detecting page visibility and user activity. It wraps the standard Page Visibility API to surface focus/blur events, and adds an idle-detection system that fires `idle`/`wakeup` events after a configurable period of user inactivity (mouse, keyboard, touch, scroll). Version 3 is a complete rewrite in TypeScript with per-instance event isolation, SSR-safe construction (no DOM access at import time), and support for the Page Lifecycle API (`freeze`/`resume` for bfcache). The library ships as an ESM module, CommonJS, and an IIFE global, with bundled type definitions. It is designed for use in any client-side JavaScript project—SPA frameworks, traditional websites, or even server-side rendering environments (where it becomes a safe no-op). The architecture is simple: a single `IfVisible` class holds an internal `EventEmitter` and a `Timer` class for smart intervals that auto-pause when the user is idle. The codebase is well-structured, thoroughly tested (including an SSR test), and follows modern best practices. It is not a data research project; it is a reusable application library.