npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

perceptible

v1.0.1

Published

detect visibility of DOM Elements

Readme

Perceptible

Zero-dependency JavaScript library for high-performance DOM element viewability and visibility tracking.

Perceptible monitors DOM elements in real time as users scroll and interact. It measures exact surface area coverage relative to the browser viewport while handling tab visibility, window focus events (attentionMode), and visibility duration.

Perceptible can be used to detect viewability of any DOM element that the user is currently looking at. A Element may be part of the page but not under current viewport (due to user scroll), perceptible helps to calculate viewability for such elements for analytics and other purpose.

In addition to view port, it also considers page focus and switching of tabs while calculating the visibility of element. Entire visibility duration of the element is also reported.

Perceptible is highly configurable and easy to use.

View the sample using npm run sample

CI PRs Welcome GitHub issues


Key Use Cases

  • Analytics & Impression Telemetry: Track active impression duration for banner ads and content cards.
  • Ad Viewability Standards: Measure MRC compliance (e.g. 50% visibility for >1 second).
  • A/B Testing & Content Engagement: Quantify content exposure metrics.
  • Lazy Loading Triggers: Trigger asset fetching when elements enter viewport bounds.
  • Media Player Automation: Monitor visibility of video/audio elements to auto-pause or trigger Picture-in-Picture mode.

Documentation

Full documentation is built with Docusaurus and available under the documentation directory or hosted online at perceptible.netlify.app.

Usage with Packages (Example App)

For modern bundlers (like Vite, Webpack, or Rollup), you can import perceptible as an ESM/CommonJS module.

Basic Usage

import Perceptor from 'perceptible';

const element = document.querySelector('#target');
const perceptor = new Perceptor(element, {
  threshold: 0.5 // trigger when 50% of the element is visible
});

perceptor.subscribe((event) => {
  console.log('Element visibility changed:', event);
});

perceptor.watch();

Running the Example Application

A complete Vite-based sample app demonstrating package usage is available in the example directory. To run it:

  1. Build the perceptible library from the root directory:
    npm run build
  2. Navigate into the example directory:
    cd example
  3. Install dependencies:
    npm install
  4. Start the Vite development server:
    npm run dev

Development & Testing

This project uses Node.js (>=24) and Vite as its module bundler. For complete testing guidelines and agent instructions, refer to the Testing Guide.

Installation & Scripts

# Install dependencies
npm install

# Build distribution bundle (Vite outputs dist/bundle.js and UMD/ESM modules)
npm run build

# Start dev build in watch mode
npm run start

# Run unit tests via Jest & jsdom
npm run test

# Run tests in watch mode / coverage
npm run test:watch
npm run test:coverage

# Run automated browser tests via Puppeteer
npm run test:e2e

# Serve interactive samples locally (runs http-server on /sample)
npm run sample

# Lint codebase
npm run lint

Folder Structure

  • src - Library source code (config, schedulers, spectators, subscribers, utils, unit tests)
  • example - Modern Vite application consuming perceptible as an NPM module (import Perceptor from 'perceptible')
  • e2e - End-to-end automated browser test suite powered by Puppeteer
  • dist - Compiled distribution bundles generated by Vite
  • documentation - Modern documentation portal built with Docusaurus v3
  • media - Graphical assets and logos
  • sample - Standalone interactive HTML sample demonstrations consuming dist/bundle.js

Roadmap

  • [x] Extensible core framework with default Spectators & Subscribers
  • [x] Docusaurus documentation portal with live examples
  • [x] Unit Test Suite powered by Jest & JSDOM (npm run test)
  • [x] Puppeteer automated browser testing (npm run test:e2e)

Contribution

Suggestions and Pull Requests are welcome! Please read the contribution guidelines to get started.


License

Open Source Love

Released under the MIT License.