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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hash-web

v1.2.1

Published

A script that appends hashes to filenames, import paths, and any other links for your web project.

Downloads

318

Readme

HASH-WEB

A script that appends hashes to filenames, import paths, and any other links that connect the resources within your entire web project.

How does it work?

The script requires an HTML entry point to begin. It scans the page for links specifically those with src="" or href="", and follow these links to subsequent files. For each files, depending on its content type (e.g, .js, .css) the script performs an additional scan to identify and track any further links to other resources. For example, when processing a JS file, the script looks for patterns such as import, fetch, request, and url.

As it processes each resource, the script generates a unique hash based on the file's content and appends this hash to the corresponding links. Simultaneously, the script copies all the files to an output folder, ensuring that resources are organized and properly linked.

This script is designed to work with any web project, as long as it used as a post-build step in your workflow.

Why?

Force the update of your website for users who most likely have a cached version. By changing the file path, the browser is forced to fetch the latest version, ensuring users get the update immediately without needing to manually clear their cache or wait for it to expire.

If a file doesn't change, its hash remains the same, and the browser will serve the cached version regardless.

How to use?

Program

hash-web ./public/index.html ./build

API

hash_web({
  input: `./public/index.html`,
  output_dir: `./build`
});

Handle links

| Ext | Patterns | |-----|----------| | .html | src="", href="", <script></script>, srcset="", <object data="">, content="" | | .css | url("") | | .js | import, fetch, new URL, new Request | | .webmanifest | "src": "" |