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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@hortonstudio/main

v1.9.39

Published

Animation and utility library for client websites

Readme

@hortonstudio/main

Version: 2.0.0

Auto-initializing JavaScript library for Webflow sites with animations, accessibility, and utility functions.


Installation

Standard Installation

<script type="module" src="https://cdn.jsdelivr.net/npm/@hortonstudio/main@2/dist/main.js"></script>
<script>document.documentElement.classList.add('hs-main');!function t(){hsmain?.afterReady?hsmain.afterReady(()=>{hsmainReady=!0,dispatchEvent(new Event('hsmain:ready'))}):setTimeout(t,50)}()</script>

Local Development:

<!-- Local testing (run: npm run dev) -->
<script type="module" src="http://localhost:5173/index.ts"></script>
<script>(function(){function w(){if(window.hsmain?.afterReady){window.hsmain.afterReady(function(){window.hsmainReady=true;window.dispatchEvent(new Event('hsmain:ready'))});}else{setTimeout(w,50);}}w();})();</script>

SPA Mode (Barba.js, Swup, etc.): Add data-hs-spa="true" to the module loader

<script type="module" src="https://cdn.jsdelivr.net/npm/@hortonstudio/main@2/dist/main.js" data-hs-spa="true"></script>
<script>(function(){function w(){if(window.hsmain?.afterReady){window.hsmain.afterReady(function(){window.hsmainReady=true;window.dispatchEvent(new Event('hsmain:ready'))});}else{setTimeout(w,50);}}w();})();</script>

Configuration

// Example: Barba.js integration
barba.hooks.before(() => {
  window.dispatchEvent(new CustomEvent('hsmain:transition-exit'));
});

barba.hooks.after(() => {
  window.dispatchEvent(new CustomEvent('hsmain:transition-enter'));
});

API Usage

External Script Integration

When using external scripts & libraries (Barba.js, GSAP ScrollTrigger, etc.) that need to wait for hsmain to be ready, the inline helper script (included with standard installation) ensures window.hsmain is available.

External scripts should use the callback pattern:

<script>
window.hsmain?.afterReady(() => {
  // Your code here
});
</script>

Why this works:

The inline helper script (included in standard installation) polls for window.hsmain to exist and calls afterReady() once initialization completes. This guarantees that by the time your external script runs, window.hsmain exists and afterReady() will fire either immediately (if already ready) or when initialization completes.

Cleanup

// Destroy all modules (useful for SPA navigation)
window.hsmain.destroy();

// Reinitialize everything
await window.hsmain.reinitialize();

Manual Module Loading

// Load a single module
window.hsmain.load('counter');

// With callback
window.hsmain.push([
  'counter',
  () => {
    console.log('Counter module ready');
  },
]);

Lifecycle Hooks

// Execute code after all modules load
window.hsmain.afterReady(() => {
  console.log('Library fully initialized');
});

// Check module status
const status = window.hsmain.status('counter');
console.log(status); // { loaded: true, loading: false }

Modal Manager & Lenis Integration

Modal manager automatically detects and handles Lenis smooth scroll (stops on modal open, starts on close).

// Auto-detection works with zero config
// Just use modals normally - Lenis is handled automatically

// Disable auto Lenis handling if needed
window.HS.modal.setLenisEnabled(false);

// Manual modal control
window.HS.modal.open();
window.HS.modal.close();

// Custom callbacks (run in addition to auto Lenis handling)
window.HS.modal.onOpen(() => {
  console.log('Modal opened');
});

window.HS.modal.onClose(() => {
  console.log('Modal closed');
});

Architecture

  • TypeScript: Full type safety with TypeScript source
  • Vite Bundled: Optimized build with code splitting (~24kb gzipped total)
  • Config-driven: Centralized configuration in config.json
  • SPA Compatible: Works with Barba.js, Swup, and other routers
  • Memory Safe: Proper cleanup tracking for observers and event handlers
  • Phase-based Loading: Optimized initialization sequence