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

backpopup.js

v1.0.1

Published

Show customizable popups on browser back action — ideal for exit-intent offers, surveys & lead capture. Pure JavaScript, no jQuery.

Readme

BackPopup.js

npm version

License: MIT

BackPopup.js is a lightweight JavaScript library that shows a customizable popup when users press the browser's back button — great for last-chance offers, surveys, or exit-intent lead capture.


🚀 Features

  • 🔁 Triggers on browser back button
  • 🧠 “Don’t Show Again” using localStorage or cookies
  • ⚡ Smooth fade-in and pop-in animation
  • 🎯 Fully customizable: title, message, image, CTA, decline button
  • 📦 Zero dependencies, pure JavaScript

📦 Installation

Option 1: Direct <script> Include

<script src="backpopup.js"></script>

Or use the minified version:

<script src="backpopup.min.js"></script>

Option 2: Install via npm

npm install backpopup

Then use it in your JavaScript:

import BackPopup from 'backpopup';

BackPopup.init({
  title: "WAIT!",
  message: "Don't leave yet — there’s an exclusive offer waiting!",
  ctaText: "Claim Offer",
  ctaUrl: "https://example.com",
  declineText: "No thanks"
});

🛠️ Usage

<script>
BackPopup.init({
  title: "WAIT!",
  message: "Don't leave yet — there’s an exclusive offer waiting!",
  image: "offer.jpg", // optional
  subtext: "Complete a quick survey and claim your reward.",
  ctaText: "Yes, I want it!",
  ctaUrl: "offer.php",
  declineText: "No thanks",
  animationDuration: 300, // optional
  useCookies: true,       // enable cookie mode instead of localStorage
  cookieExpiryDays: 7     // valid only if useCookies is true
});
</script>

⚙️ Options

| Option | Type | Description | | ------------------- | ------- | --------------------------------------------------------------- | | title | string | Main heading of the popup | | message | string | Message below the title | | image | string | (Optional) Image URL | | subtext | string | Message under the image | | ctaText | string | Text on the call-to-action button | | ctaUrl | string | URL for the CTA button | | declineText | string | Text for the dismiss link | | animationDuration | number | Animation speed in milliseconds (default: 300) | | useCookies | boolean | If true, uses cookies instead of localStorage | | cookieExpiryDays | number | Cookie expiry in days (only used when useCookies is true) |


🧠 “Don't Show Again” Behavior

Once the user clicks "No thanks", the popup won't appear again due to:

  • localStorage flag (backPopupDismissed) if useCookies: false (default)
  • A cookie (backPopupDismissed) if useCookies: true

🔄 Reset manually (for development):

For localStorage mode:

localStorage.removeItem("backPopupDismissed");

For cookie mode:

document.cookie = "backPopupDismissed=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";

💡 Tips

  • Combine with UTM parameters or cookies for targeted campaigns
  • Customize appearance using your own CSS overrides
  • Works well for landing pages, checkout exits, and surveys

📝 License

MIT License


🙋 Support

Found a bug or want a new feature? Open an issue or contact the maintainer.