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

hpack-html-js

v0.1.0

Published

Pure JS HTML compressor for the .hpack format — browser, Chrome extension, Flutter

Readme

hpack-html-js

npm License

Pure JavaScript HTML compressor for the .hpack binary format. Designed for browsers, Chrome extensions, Flutter JS bridges, and any JS runtime. Zero WASM dependencies, ~8KB gzipped.

Install

npm install hpack-html-js

Usage

import { pack } from 'hpack-html-js';

const html = '<html>...</html>';

const packed = await pack(html, {
  url: 'https://example.com/page',
  etag: '"abc123"',
  signature: 'req-sig-xyz',
});

// Send packed bytes to server (~80% smaller)
await fetch('/ingest', { method: 'POST', body: packed });

API

pack(html, options)

Compress HTML into a compact .hpack binary packet.

  • html: string — raw HTML to compress
  • options.url: string — source page URL (required)
  • options.etag?: string — HTTP ETag
  • options.signature?: string — request signature for server-side identification
  • options.contentType?: string — original Content-Type
  • options.timestamp?: number — capture time (Unix ms, defaults to Date.now())
  • options.encoding?: string — page encoding (defaults to "utf-8")
  • options.custom?: Record<string, string> — arbitrary key-value metadata
  • options.level?: 'fast' | 'default' | 'max' — compression level (default: "default")
  • options.minify?: boolean — minify HTML before compression (default: true)
  • options.checksum?: boolean — include CRC32 checksum (default: true)
  • Returns Promise<Uint8Array>

minify(html)

Standalone HTML minifier. Removes comments, collapses whitespace, sorts attributes, removes optional closing tags.

  • html: string — raw HTML
  • Returns string — minified HTML

compress(data, level?)

Low-level compression. Uses native CompressionStream when available, falls back to fflate.

  • data: Uint8Array — bytes to compress
  • level?: 'fast' | 'default' | 'max'
  • Returns Promise<{ compressed: Uint8Array, isGzip: boolean }>

Compression Pipeline

Raw HTML (100KB)
  -> Minify (whitespace, comments, attr sorting)  ->  ~85KB
  -> DEFLATE (via fflate or native CompressionStream)  ->  ~21KB
  -> Encode .hpack (magic + headers + body + CRC32)  ->  ~21.2KB

Browser Compatibility

| Environment | Compression Engine | Bundle Cost | |-------------|-------------------|-------------| | Modern browsers (95%+) | Native CompressionStream | 0KB | | Older browsers | fflate fallback | 8KB | | Chrome Extension | fflate (CSP-safe, no WASM) | 8KB | | Flutter JS bridge | fflate | 8KB | | Node.js / Bun / Deno | Native CompressionStream | 0KB |

Decompression

To decompress .hpack packets, use hpack-html (TypeScript) or the hpack-html Rust crate.

Real-World Results

| Page | Raw | Packed | Reduction | |------|-----|--------|-----------| | Americanas.com.br | 101.6 KB | 22.0 KB | 78.4% | | Wikipedia | 489.8 KB | 89.7 KB | 81.7% | | Hacker News | 33.7 KB | 5.8 KB | 82.7% | | Google BR | 176.8 KB | 55.1 KB | 68.8% | | Cloudflare Blog | 105.7 KB | 19.1 KB | 82.0% |

Lossless: unpack(pack(html)) === html verified byte-by-byte on all pages.

License

Apache License 2.0 — See LICENSE for details.