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

lazytree-react

v1.0.1

Published

A React component for displaying large nested lists.

Readme

LazyTree

A React component for displaying large nested lists. Implements lightweight DOM updates on scroll, and lazy-loading nested list data.

Demo

This video shows the demo included in the demo directory:

LazyTree demo

This is the same demo with the DOMViz Chrome extension enabled, highlighting DOM mutations:

LazyTree demo using the DomViz Chrome extension

The mutation highlights show that DOM nodes (list items) are added as they enter the view. A node enters the view when scrolled to, or when its parent node is expanded.

Installation

npm install lazytree-react

Usage

(See the demo directory for a complete example.)

Do a require on the JSX file:

var LazyTree = require('lazytree.jsx');

Initialize the LazyTree component with the loadChildren, nodeHeight, and 'rootElement props:

var root = $("#root")[0];
<LazyTree
    loadChildren={loadChildren}
    nodeHeight={30}
    rootElement={root}
/>

The props are as follows:

  • loadChildren: callback to load child nodes (see demo/demo.jsx for full callback docs)
  • nodeHeight: height of all nodes (in px)
  • rootElement: element to mount LazyTree component into

Description

LazyTree allows efficient exploration of large, deeply nested lists.

Internally, LazyTree acts as a parent component for a nested list of LazyNode components:

  • LazyTree
    • LazyNode 1
    • LazyNode 2
      • LazyNode 2,1
      • LazyNode 2,2
      • ...
    • LazyNode 3
    • ...
    • LazyNode N

Here:

  • LazyTree is the top-level parent component
  • LazyNode 2 is the parent of LazyNode 2,1 and LazyNode 2,2
  • LazyNode 1 is a sibling of LazyNode 2

LazyTree component

The top-level LazyTree component maintains an internal data structure representing the tree state, where a given node is ...

  • expanded (children deployed) or collapsed (children not deployed)
  • deployed (parent expanded) or not deployed (parent collapsed)
  • visible or occluded (UI state)

LazyNode component

Each LazyNode component uses callbacks passed down from LazyTree to query the tree state to determine ...

  • should I be rendered? (ie am I currently visible?)
  • should my children be rendered? (ie am I currently expanded?)
  • which of my children should be rendered? (ie which children are visible?)

The process for determining which children should be rendered is:

  • binary search for visible children
  • find first visible child
  • find first occluded child below it

LazyTree achieves efficiency via lightweight DOM updates and lazy-loading nested list data.

Lightweight DOM updates

The internal data structure representing the tree state maintains the state of each node in the UI:

  • occluded
  • expanded

A LazyNode's children are searched to find the ones that are currently visible, and only then added to the virtual DOM for rendering.

Lazy-loading child nodes

The loadChildren callback provided to LazyTree is used to lazy-load child node labels for the given parent node.

Lazy-loading sibling nodes

On the TODO list is lazy-loading sibling data on scroll (paging).

License

Apache 2.0

TODO:

  • Implement lazy-loading scroll with loadSiblings callback (could use Waypoint)
  • Fix scrollbar so it shows full size of list