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

cherry-html

v1.0.2

Published

High-performance HTML parser and DOM manipulation library in Rust

Downloads

378

Readme

<🍒/> cherry-html

cherry-html is a high-performance HTML parser and DOM manipulation library built in Rust using napi-rs for Node.js. It provides a blistering fast native API for manipulating HTML structures, a compatible cheerio-like wrapper for ease of use, and a streaming parser to evaluate CSS selectors on the fly as data arrives!

Features

  • Blazing Fast: Uses html5ever and scraper under the hood.
  • Native Parser: Parse once and query multiple times with maximum performance.
  • Cheerio-like API: An easy, drop-in API designed to mimic the familiar cheerio interface while being powered by our Rust backend.
  • Streaming Parser: Apply CSS selectors directly on an incoming stream of HTML chunks.

Installation

npm install cherry-html

1. The Cheerio-like API (Highly Recommended)

If you are coming from cheerio, you can use our API which matches Cheerio's syntax very closely while being backed entirely by the native Rust parser. This gives you the extreme speed of Rust while keeping the syntax you are already familiar with.

const { load } = require('cherry-html/cheerio');

const html = `
  <ul id="fruits">
    <li class="apple">Apple</li>
    <li class="orange">Orange</li>
    <li class="pear">Pear</li>
  </ul>
`;

const $ = load(html);

// Query elements
console.log($('.apple').text()); // "Apple"

// Manipulate DOM
$('#fruits').append('<li class="plum">Plum</li>');
$('.orange').removeClass('orange').addClass('tangerine');

// Iterate
$('li').each((i, el) => {
  console.log($(el).text());
});

Available Cheerio Methods

Currently supported:

  • Selectors: $(selector), .find(selector), .parent(), .children(), .eq(index), .first(), .last()
  • Attributes/Classes: .attr(name), .attr(name, value), .removeAttr(name), .addClass(name), .removeClass(name)
  • Manipulation: .text(), .text(str), .html(), .html(str), .append(str), .prepend(str), .remove()
  • Iteration: .each(fn), .map(fn), .toArray()

2. Native API

[!WARNING]
We strongly recommend against using the Native API directly. The cheerio-like API (Section 1) utilizes advanced Rust thread-locking and batching optimizations that make it significantly faster than the raw Native API.

If you absolutely must skip the convenience API and interact with the raw Rust bindings directly, you can use the native API.

const { parse } = require('cherry-html');

const document = parse('<div class="container"><p>Hello World</p></div>');

// querySelectorAll returns an array of native `Element` objects
const elements = document.querySelectorAll('.container p');

for (const el of elements) {
  console.log(el.text()); // "Hello World"
  el.setHtml('<b>Updated!</b>');
}

Available Native Methods

  • Document: .querySelectorAll(selector)
  • Element:
    • .text(), .setText(text)
    • .html(), .setHtml(html)
    • .attr(name), .setAttr(name, value), .removeAttr(name)
    • .addClass(name), .removeClass(name)
    • .append(html), .prepend(html), .remove()
    • .parent(), .children(), .querySelectorAll(selector)

3. Streaming API

Parse and capture elements matching specific selectors as HTML chunks arrive over the network, without keeping the entire document tree in JavaScript memory. The library provides a native Node.js Writable stream wrapper that automatically converts matched elements into cheerio-like objects!

const { createStream } = require('cherry-html/stream');
const fs = require('fs');

// Register the selectors you want to track
const stream = createStream({
  selectors: ['.important-data', 'a.external-link']
});

// The 'selectors' event fires when the stream is finished parsing
stream.on('selectors', (results) => {
  // `results` is an object mapping selectors to Cheerio-like instances
  const importantData = results['.important-data'];
  const links = results['a.external-link'];

  console.log(importantData.text());
  
  links.each((i, el) => {
    console.log(el.attr('href'));
  });
});

// Since it's a standard Writable stream, you can pipe any data source into it!
// E.g., from a file:
fs.createReadStream('large-file.html').pipe(stream);

// Or from an HTTP request:
// https.get('https://example.com', (res) => res.pipe(stream));

🚧 Coming Soon (Missing Functions)

I am actively developing cherry-html. The following functions and features are currently missing but will be added soon:

  • Advanced structural manipulation (.before(), .after(), .replaceWith(), .empty())
  • Sibling traversal (.next(), .prev(), .siblings())
  • Form data serialization (.serialize(), .val())
  • Data attributes handling (.data())
  • More robust and complex CSS pseudo-selectors support in the native engine.

Acknowledgements & Credits

cherry-html stands on the shoulders of giants. A huge thank you to the following open-source projects that make this library possible:

  • napi-rs: The incredible framework for building pre-compiled Node.js addons in Rust.
  • scraper: The robust HTML parsing and querying library for Rust.
  • html5ever: The blazing-fast HTML5 parser developed by the Servo project.
  • cheerio: For designing the elegant, jQuery-like API that developers know and love.

License

MIT