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

ajax-diff

v0.0.1

Published

Automatically fetch local links with ajax and merge them into the current document.

Downloads

14

Readme

This browser module quickly ajaxifies any site. It automatically fetches all your local links with ajax, compares the fetched document with the current one using diff-dom, then merges head and body changes into the current page.

Inspired by Turbolinks.

Installation

npm install ajax-diff

Simple Usage

// Import the module.
import * as ajaxDiff from 'ajax-diff'

// Start handling links.
ajaxDiff.start()

Now you have a smart single-page ajax site!

Advanced Usage

Optionally pass a configuration object:

ajaxDiff.start({
  // Query selector defines which elements to bind the ajax handler to. (Only anchor elements are supported.)
  elemSelector: 'a[href]:not([target]):not([download])',

  // Use MutationObserver to automatically bind listeners to changed or newly added elements.
  observeMutations: true,

  // Use native Element.scrollIntoView when navigating to anchors. (Polyfill not included.)
  smoothScrollAnchors: false,
})

You can also invoke ajax navigation manually:

ajaxDiff.navigate('/', {
  // Whether to create a new history state.
  pushHistory: true,

  // Defaults to the option already passed to start(), otherwise false.
  smoothScrollAnchor: false,
})

Some events are dispatched during navigation:

document.addEventListener('AjaxContentRequested', event => {
  // We have started an ajax request for a local page.

  // Event data:
  //   event.detail.url
})

document.addEventListener('AjaxContentRejected', event => {
  // We got a bad response from the server and have ceased loading.

  // Event data:
  //   event.detail.response
})

document.addEventListener('AjaxContentWillLoad', event => {
  // We got a valid response and are preparing to merge the fetched document.
  // Perform any processing/transformations on the fetched document here.

  // Event data:
  //   event.detail.response
  //   event.detail.document
})

document.addEventListener('AjaxContentLoaded', event => {
  // Merging is complete and the DOM has been modified to reflect changes.

  // Event data:
  //   event.detail.response
})