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

liveinit

v0.1.0

Published

Lean HTML-first component initializer and command delegator

Readme

liveinit

A radically lean, ultra-fast, HTML-first application loader and DOM lifecycle observer.

liveinit provides a robust architecture for initializing Javascript components and delegating stateless actions safely without memory leaks, massive framework overhead, or Virtual DOMs. It bridges the gap between server-rendered HTML and client-side interactivity by turning standard HTML data attributes into reactive lifecycle hooks and event delegations.

It is heavily inspired by Stimulus, Alpine, and GitHub Catalyst, but stripped down to the absolute bare minimum (~150 lines of dependency-free modern Javascript).

Key Advantages

  • Zero Global Listeners Overhead: The declarative data-command engine uses a single, global event listener delegator that catches bubbling actions. No tracking individual buttons, no multiple active listeners—saving memory and CPU.
  • GC & Memory Safe: initComponents seamlessly constructs an AbortController. When DOM nodes are removed or replaced (e.g., via AJAX/HTMX), all associated event listeners are instantly aborted and garbage collected cleanly.
  • O(1) Evaluation Pattern: Instead of walking entire DOM trees upon mutations, the core observer relies on blazing-fast native querySelectorAll with pre-compiled CSS strings.
  • Graceful Lazy-Loading: Built-in IntersectionObserver optionally defers executing components until the user actually scrolls the element into view.
  • HTML-first: Maintain beautiful, standard HTML strings. The parser natively understands relaxed JSON configuration strings, requiring no compilation steps or esoteric syntax constraints inside your templates.

Quick Start

CDN / no-build (fastest setup):

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/liveinit.min.js" defer></script>
<div data-component="Counter" data-component-config="start: 10"></div>
<button data-command="refresh" data-command-for="#my-table">Reload Data</button>
<table id="my-table"></table>

<script>
  class Counter {
    constructor(el, config) {
      el.textContent = `Count: ${config.start || 0}`;
    }
  }
  window.Counter = Counter; // default resolver reads from window

  document.addEventListener("command:refresh", () => {
    console.log("refresh table");
  });
</script>

Everything is configurable (custom attributes, event list, resolver, lifecycle hooks, lazy behavior).
See docs/initComponents.md and docs/initCommands.md for full options.

Safe Script Loading

liveinit is structurally immune to script load order issues because of its core architecture:

  1. MutationObserver foundation: Even if liveinit executes before your HTML finishes rendering, it will instantly catch and initialize elements as they stream into the <body>.
  2. Global Delegation: initCommands() attaches listeners to the document root, meaning it doesn't care if the target buttons exist yet or are added asynchronously later.

To guarantee zero race-conditions and best performance, load the script high up in the document (like the <head>) with defer:

<script src="..." defer></script>

Bundler usage:

import { initComponents, initCommands } from "liveinit";

initComponents({
  dropdown: () => import("./components/dropdown.js"),
  "heavy-map": () => import("./components/map.js"),
});
initCommands();

Documentation

The library consists of modular, standalone pieces you can use together or separately:

  1. API Contract - Stable public exports and return shapes.
  2. Init Components Engine (initComponents.js) - The main application loader tying everything together.
  3. Command Engine (initCommands.js) - The global configurable event delegator for stateless HTML actions.
  4. Selector Observer (observer.js) - The ultra-fast MutationObserver wrapper.
  5. Lazy Init (lazy.js) - The IntersectionObserver bindings for deferred loading.
  6. Data Config (parseConfig.js) - A relaxed, HTML-friendly JSON parser.

Browser Support

  • liveinit targets browsers with native ES modules (<script type="module">) and modern DOM APIs.
  • IntersectionObserver is optional: if unavailable, lazy() falls back to immediate initialization instead of throwing.
  • The table below reflects the baseline for the full feature set (type="module" + AbortController + core DOM APIs used by this library).

| Browser | Minimum version | First stable release | |---------|-----------------|----------------------| | Chrome | 66 | April 17, 2018 | | Firefox | 57 | November 14, 2017 | | Safari | 12.1 | March 25, 2019 | | Edge | 16 | October 17, 2017 |

Semver Policy

  • Patch releases (x.y.z) include bug fixes and internal changes only.
  • Minor releases (x.y.0) can add new features/options in backward-compatible ways.
  • Major releases (x.0.0) are used for breaking changes.

Breaking changes include:

  • Renaming/removing public exports from liveinit.
  • Changing default attribute names or command event naming behavior.
  • Changing lifecycle contracts (for example return shapes from initCommands() or observer engine APIs).
  • Raising the documented browser support baseline.