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

@youneed/dom-provider-virtual

v0.1.0

Published

Composable @youneed/dom provider for IntersectionObserver-driven list virtualization (this.virtual) — only visible chunks render.

Readme

@youneed/dom-provider-virtual

IntersectionObserver-driven list virtualization for @youneed/dom: render a list of thousands of items but keep only the on-screen rows as real DOM. A composable component provider (the same shape as the other dom-provider-* packages — i18n/a11y/…): install virtualProvider() and call this.virtual(...) from render(). A standalone virtual() function is exported for use without the provider.

Install

pnpm add @youneed/dom-provider-virtual

Use (provider)

import { Component, html } from "@youneed/dom";
import { virtualProvider } from "@youneed/dom-provider-virtual";

class Feed extends Component("x-feed", { providers: [virtualProvider()] }) {
  @Component.prop() rows: Row[] = [];

  render() {
    return html`${this.virtual({
      items: this.rows,
      render: (r) => html`<div class="row">${r.title}</div>`,
      estimateHeight: 40,
    })}`;
  }
}

Or without the provider, calling virtual() directly:

import { virtual } from "@youneed/dom-provider-virtual";

render() {
  return html`${virtual({ items: this.rows, render: (r) => html`<div>${r.title}</div>` })}`;
}

How it works

The list is split into fixed-size chunks, one <vm-virtual-chunk> rendered per chunk. A single IntersectionObserver (rooted on the scroll viewport, with an overscan margin) watches every chunk; as a chunk scrolls into view its active prop flips and — thanks to @youneed/dom's per-component isolation — only that chunk re-renders its items. Off-screen chunks collapse to a spacer of their last measured height, so the scrollbar stays correct and the parent list never re-renders on scroll.

SSR: with no IntersectionObserver, chunks render as placeholders; the client hydrates and the observer fills the visible ones. v1 covers vertical lists with a per-item height estimate; variable heights settle via measurement.

API

  • virtualProvider()ComponentProvider<{ readonly virtual: VirtualApi }> — drop into Component(tag, { providers: [...] }); exposes this.virtual(opts).
  • virtual<T>(opts)TemplateResult — standalone; embed the result in a component's html. Typed over the item type, so render/key get the real type.
  • VirtualOptions<T>items (the full dataset), render(item, index) (index is the global index), optional key(item, index) (defaults to global index), chunkSize (items per chunk, default 20), estimateHeight (px per item before measurement, default 32), overscan (px kept rendered above/below the viewport, default 400).
  • VirtualList, VirtualChunk — the underlying custom elements (vm-virtual-list / vm-virtual-chunk), exported for advanced use.

Config is passed as one object prop (.data=${…}) on purpose: HTML lowercases attribute names, so a .camelCaseProp=${…} template binding would silently miss — a single data prop keeps the camelCase option names intact.

Peer: @youneed/dom.