Visibility.js is a small JavaScript library that wraps the native Page Visibility API to give developers an easy interface for detecting when a user’s browser tab becomes visible, hidden, or is in prerendering mode. Its main purpose is to let web applications adapt behavior depending on whether the page is actually being viewed — for example, pausing animations, postponing heavy computations, or stopping unnecessary network requests when the user switches to another tab. The library hides browser vendor-prefixes and normalizes visibility events so you don’t have to manage cross-browser quirks yourself. On top of simple visibility detection, Visibility.js adds useful helpers such as a timer function that only runs when the page is visible. As a result, developers can write resource-conscious web apps that reduce CPU/bandwidth usage when the user isn’t actively viewing the page.

Features

  • Simple abstraction over the Page Visibility API with normalized events and states
  • Ability to run timers (every) only when the page is visible, saving resources when hidden
  • Callbacks like onVisible, onHidden, change to execute logic on visibility state changes
  • Fallback mode using focus/blur events for browsers lacking native Page Visibility support
  • Easy installation via npm and straightforward API usage for web developers
  • MIT-licensed and sufficiently lightweight for inclusion in most web apps

Project Samples

Project Activity

See All Activity >

Categories

Browsers

License

MIT License

Follow Visibility.js

Visibility.js Web Site

Other Useful Business Software
Gen AI apps are built with MongoDB Atlas Icon
Gen AI apps are built with MongoDB Atlas

The database for AI-powered applications.

MongoDB Atlas is the developer-friendly database used to build, scale, and run gen AI and LLM-powered apps—without needing a separate vector database. Atlas offers built-in vector search, global availability across 115+ regions, and flexible document modeling. Start building AI apps faster, all in one place.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Visibility.js!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

JavaScript

Related Categories

JavaScript Browsers

Registered

4 days ago