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

@amazinglynormal/prefetch

v0.1.4

Published

Prefetch is a zero-dependency library for dynamically prefetching or prerendering web pages.

Downloads

12

Readme

Prefetch

Prefetch is a zero-dependency library for dynamically prefetching web pages.

Quick start

With npm installed, run:

npm install @amazinglynormal/prefetch
// index.js
import { watch } from "@amazinglynormal/prefetch";

window.addEventListener("DOMContentLoaded", () => {
    watch();
});

This basic usage will use all default options:

Watch all anchor tags <a> that link to same-site resources. Prefetch any link that come into the viewport. If more than one anchor links to the same resource, it will only be requested once.

Note: If your user has save-data enabled or a slow connection is detected, no prefetch request will be sent.

API

watch([options])

watch can be confgured by passing an optional options object.

options.triggerEvent: "inView" | "onHoverOrFocus" | "onPointerOrKeyDown"

Default: "inView"

The UI event that triggers a prefetch request.

  • "inView": prefetch is triggered when element comes into viewport.
  • "onHoverOrFocus": prefetch is triggered when user hovers over the element with a mouse or when the element has received focus.

Note: Most Mobile devices do not have a "hover" state because there's no mouse pointer and focus can also be handled a bit differently on mobile browsers. Therefore, "onHoverOrFocus" may only be an appropriate option if you're primarily targeting desktop users.

  • onPointerOrKeyDown: prefetch is triggered when pointerdown or "Enter" keydown event is on a element.

Note: Least aggressive prefetching strategy. It is more so used to give the request a head start as you can be almost certain user intends to go to linked page.

options.elements: HTMLAnchorElement | NodeList

Note: If neither options.elements or options.selectors are passed in the options object, default selector of "a" is used.

Default: null

The anchor element <a> or NodeList of anchor elements you wish to watch.

options.selectors: string[]

Note: If neither options.elements or options.selectors are passed in the options object, default selector of "a" is used.

Default: null

An array of CSS selectors to query in the document and watch.

options.delayMilliseconds: number

Default: 0

The number of milliseconds anchor element <a> must be in the viewport before prefetch request is triggered.

options.ignore: string[]

Default: []

An array of hrefs you want ignored. This option overrides both options.elements and options.selectors.

options.inViewThreshold: number (0 - 1)

Default: 0

The percentage of the element visible in the viewport before prefetch request is triggered. An inViewThreshold of 1 means 100% of element must be in viewport for the prefetch request to trigger.

options.prerenderWhenPossible: boolean

Default: false

Please carefully consider which pages you would like to prerender

Will append make prerender rather than prefetch request.

Note: If Speculation Rules API is not supported by users browser, prefetch will be used as a fallback.

Other Resources

License

MIT