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 🙏

© 2025 – Pkg Stats / Ryan Hefner

schwifty.js

v0.1.1

Published

An ultra-light and ultra-fast page loader for static sites.

Downloads

3

Readme

The Schwifty.js Logo

Schwifty.js

Instant page loads for static sites.

How it works

Schwifty preloads and caches same-origin HTML documents, using an asynchronous XHTTP request.

Usage

Once you create a new instance of Schwifty, it will automatically start preloading and caching same-origin links in the current document.

import Schwifty from 'Schwifty';
new Schwifty();

Options

options.onload

  • Type: function
  • Default: null

This is the callback that runs when a new page is rendered. Use it to re-run Javascript on each page load.

function doStuff() {
	// Do stuff
}

new Schwifty({
	onload: doStuff // Called once the new page is rendered
})

This parameter also accepts an array of functions.

new Schwifty({
	onload: [
		doStuff,
		doMoreStuff,
		doEvenMoreStuff
	]
})

options.selector

  • Type: string
  • Default: a[href^="${window.location.origin}"]:not([data-no-schwifty]), a[href^="/"]:not([data-no-schwifty])

This is the selector passed to document.querySelectorAll, which returns valid links for preloading.

options.cacheLimit

  • Type: number
  • Default: 85

This is the maximum number of pages Schwifty will preload before the cache is "full". When new pages are added to the cache, the oldest entries will be dumped to make room.

options.preserveScroll

  • Type: boolean
  • Default: false

This tells Schwifty whether or not to preserve the scroll position upon loading a page.

options.preserveAttributes

  • Type: boolean or object
  • Default: false

This tells Schwifty whether or not to preserve attributes on top-level DOM elements (documentElement, head, and body).

preserveAttributes: {
	documentElement: true,
	body: true,
	head: false
}
// Or
preserveAttributes: true

options.transitioningAttribute

  • Type: string
  • Default: data-schwifty

This is the attribute added to the documentElement during a page transition.

transitioningAttribute: 'data-isTransitioning'
<!-- Before page transition -->
<html>...</html>

<!-- During page transition -->
<html data-isTransitioning="">...</html>

<!-- After page transition -->
<html>...</html>

Known issues

iOS Safari (and other browsers running on top of it) won't always re-render Reader View when navigation occurs.

Schwifty emits only the standard events that occur on a page load, which usually don't trigger iOS Safari to update the content in Reader View. This can lead to a user tapping Reader View on one page, only to see the content from a page they had visited previously. The proper content is rendered only after refreshing.

Until more is known about what triggers Reader View updates, I've put a pin in trying to debug this issue.