Ifvisible.js
Crossbrowser & lightweight way to check if user is looking at the page or interacting with it.
No-build verifiedActive0 dependenciesESM + script tagTypes bundledMIT
Facts
| Size | 4.4 KB minified, 1.6 KB gzipped (dist/ifvisible.global.js) |
|---|---|
| Licence | MIT |
| Dependencies | none |
| Last release | v3.0.0, June 2026 |
| Last activity | 2026-06-12 (Active) |
| Stars | 1,952 on GitHub |
| Formats | ES module; classic script (global ifvisible); TypeScript types in the package |
| CDN hits | 279 a month on jsDelivr |
| npm downloads | 33,750 a month |
| Gates | G1 passed (no runtime dependencies); G2 passed (loads in a browser as it is); G3 passed (no compile-only entry points); G4 passed (open-source licence); G5 passed (not archived or deprecated). Smoke test on v3.0.0 in headless Chromium, 2026-10-30 |
Load it
Pin the version. The hash is computed from the file jsDelivr serves, so a changed file fails to load instead of running.
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ifvisible.global.js"
integrity="sha384-o9JkPdGxyoS4Q5hBIVWBHg+zgv9DS+u02J3+bzgjQsiN1Ayxbdm9jn2hySfs8nV9" crossorigin="anonymous"></script>import ifvisible from "https://cdn.jsdelivr.net/npm/[email protected]/dist/ifvisible.js";Advertisement
Related libraries
- Notus – Web Notifications Widget Yet another JavaScript pop-up notification library for the web.
- Speckle.js A JavaScript plugin that adds responsive, stylized speckles to any element; with no dependencies.
- Roar A zero-dependency, vanilla JavaScript alert/confirm replacement.
Entry 86 in the directory. Facts refreshed monthly; last run 2026-10-30.