{"repo":"serkanyersen/ifvisible.js","free":true,"listed":false,"github":"https://github.com/serkanyersen/ifvisible.js","clone":"git clone https://github.com/serkanyersen/ifvisible.js.git","description":"Crossbrowser & lightweight way to check if user is looking at the page or interacting with it.","language":"TypeScript","stars":1950,"topics":["coffeescript","typescript","cross-browser","visibility","javascript","npm","library","mit","utilities"],"license":"MIT","category":"dev-tools","readme_excerpt":"ifvisible.js A lightweight, cross-browser way to check whether the user is looking at the page or interacting with it. Try the interactive demo, or read on for code examples. Installation Usage ifvisible.js ships as ESM, CommonJS, and a browser global, with bundled TypeScript types. SSR-safe: importing ifvisible.js in Node / during server-side rendering never throws. In a non-DOM environment ifvisible.isSupported is false and every method is a safe no-op ( now() returns true ). v3 highlights ifvisible.js 3 is a clean-break rewrite and a major version bump. - Modern ESM + CJS + IIFE builds with bundled .d.ts types. - All legacy IE / vendor-prefix code removed; uses the standard Page Visibility API. - SSR-safe singleton — no DOM access at import time. - Per-instance event isolation (multiple new IfVisible() instances no longer share one global event store). - New freeze / resume events from the Page Lifecycle API (bfcache). - New ifvisible.destroy() to detach all listeners and timers on teardown (SPA/route unmount). Examples Handle tab switch or browser minimize states ifvisible.js can track activity states too, such as the user being IDLE or ACTIVE on the page Default idle duration is 30 seconds but you can change it with setIdleDuration method You can manually trigger status events by calling them directly, or register a handler for an event by passing a callback as the first argument: You can use ifvisible.off() to remove event triggers: You can set smart intervals with ifvi","default_branch":null,"files":null,"tree":[],"storefront":"/r/serkanyersen","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/serkanyersen/ifvisible.js/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}