Skip to content

Ping Tracker is a tiny library that adds ping attribute to all <a> tags on the site with customizable list of URLs.

License

Notifications You must be signed in to change notification settings

matronator/PingTracker

Repository files navigation

Ping Tracker

Ping Tracker logo

NPM Version NPM Downloads npm TypeScript version Tree shaking Dependencies npm package minimized gzipped size Commits Issues License CodeFactor Follow GitHub Sponsors

Ping Tracker is a tiny library that adds ping attribute to all <a> tags on the site with customizable list of URLs.

Features

  • 🏓 Add ping attribute to all <a> tags automatically
  • 👀 Watch for changes using MutationObserver to modify newly added links
  • 📝 Customize the content of the ping tag (list of URLs)
  • ⚡️ Tiny library (2.5kB minified, 1.1kB gzipped)
  • 📭 No dependencies
  • 🌳 Tree-shakeable
  • 🔥 Written in TypeScript

Installation

npm i ping-tracker

Usage

import { PingTracker } from "ping-tracker";

const pt = new PingTracker("https://analytics.example.com");

// Or with options

const pt = new PingTracker("https://analytics.example.com", {
    hrefToQuery: false,
    onlyExternal: false,
    watchDOM: true,
    elementsToWatch: document.body,
});