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

hx-prep

v1.0.0

Published

keep htmx client state across page refreshes

Readme

Enable loading skeletons in your htmx project as easy as:

<a href="/case/1" hx-prep="/skeleton" hx-prep-rule='id.innerText = "1"'>Case 1</a>

banner


Getting Started

Import the library in your client side.

CDN

<script src="https://unpkg.com/[email protected]"></script>

Bundle

To bundle in an npm-style build system with ES modules, you will have to add htmx to the document like so:

npm i hx-drag
// index.js
import "./htmx";
import "hx-prep";
// htmx.js
import htmx from "htmx.org";
window.htmx = htmx; // to support hx-drag
export default htmx;

CSS Styling

You must include these styles in your global style sheet for correct rendering during load failure after skeleton insertion, and ensuring you don't corrupt your htmx history logs.

.hx-prep { cursor: progress; }
.hx-prep, .hx-prep-skeleton, .hx-prep-origin { display: contents }
.hx-prep:has(.hx-prep-skeleton) .hx-prep-origin { display: none; }
/* OR */
@import url("https://unpkg.com/[email protected]/style.css");

These classes ensure that the original data is still visible when the skeleton is removed for history storing.

Enable

<body hx-ext="hx-prep">...</body>

HTML Attributes

All html attributes can have the data- prefix if required by your framework.

hx-prep

The url for the skeleton that can be used for any requests from this element.

hx-prep will currently override all htmx request for an element with a defined hx-prep attributes. This includes form submissions and post request among others.

To customize a skeleton on a per-element/page basis, we recommend using hx-prep-rules to customize them on the fly rather than having to load multiple different skeletons a head of time.

hx-prep-rule

Replacement rules that should be applied to the skeleton when inserted to make the skeleton unique to the element triggering it.

The first part of a prep-rule specifies which hx-prep-slot is being modified, you can then access static elements off it using the . operator to be able to change a nested property such as a style's property. The value for each rule must used " quotes, and be parsable by JSON.parse.

Each rule must be separated by a ; and any whitespace detectable by .trim() is usable around the = and ; operators.

<a
  href="/slow-page"
  hx-prep="/skeleton"
  hx-prep-rule='title.innerText = "Slow Page!"; title.style.color = "blue"'
>link</a>

hx-prep-slot

Instead of using a html id, or query selector to access an element in hx-prep-rule, we define our own attribute to allow for extra safety and precision when multiple skeletons may be present on a single page.

Skeleton

<div hx-prep-slot="body"></div>

Rule to alter inner text:

<a hx-prep-rule='body.innerText = "hello world!"'>

Http Headers

Request: HX-Prep

When a request is sent to the server of which the client will attempt to infill a skeleton, this http header will be present stating the pathname of the skeleton being used.

Request: HX-Prep-Status

This header describes if hx-prep has already successfully mounted the skeleton, or is in the process of mounting it while this request is in flight.


Examples

See https://hx-prep.ajanibilby.com/example