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
Grafana: The open and composable observability platform Icon
Grafana: The open and composable observability platform

Faster answers, predictable costs, and no lock-in built by the team helping to make observability accessible to anyone.

Grafana is the open source analytics & monitoring solution for every database.
Learn More
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

2025-11-27