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

selfopt

v0.1.0

Published

Self-Optimizing Frontend Library - Observe, detect, and prevent website decay

Downloads

86

Readme

🔮 SelfOpt — Self-Optimizing Frontend Library

Observe site health, detect decay, and apply safe optimizations.

MIT License TypeScript


The Problem

Websites decay over time even if no code changes are made:

  • Performance regressions (slower LCP, higher CLS)
  • Broken links or failed resources
  • SEO hygiene decay (missing meta tags, broken canonical URLs)
  • Browser API deprecations
  • UX instability (layout shifts, dead buttons)

Most tools are heavy, backend-driven, or dashboard-based. SelfOpt is different.

The Solution

A frontend-first, zero-backend JavaScript library that:

  • ✅ Observes site health in real-time
  • ✅ Detects decay signals using Web Vitals
  • ✅ Applies safe, transparent auto-optimizations
  • ✅ Works without any server or paid service

Quick Start

npm install selfopt
import { initSelfOpt } from 'selfopt';

// Initialize in detect-only mode (safe, default)
const selfopt = initSelfOpt();

// Get health score
console.log('Health:', selfopt.getHealth().overall); // 0-100

// Get warnings
selfopt.getWarnings().forEach(w => console.log(w.message));

// Cleanup
selfopt.destroy();

Packages

| Package | Description | |---------|-------------| | selfopt | Core runtime library | | selfopt-react | React provider and hooks | | selfopt-cli | Command-line scanner and reporter |

React Usage

npm install selfopt-react
import { SelfOptProvider, useHealth, useWarnings } from 'selfopt-react';

function App() {
  return (
    <SelfOptProvider config={{ mode: 'detect' }}>
      <Dashboard />
    </SelfOptProvider>
  );
}

function Dashboard() {
  const { health } = useHealth();
  const { warnings } = useWarnings();
  
  return (
    <div>
      <h1>Health: {health?.overall}</h1>
      <ul>
        {warnings.map(w => <li key={w.id}>{w.message}</li>)}
      </ul>
    </div>
  );
}

CLI Usage

# Scan a built site
npx selfopt-cli scan ./dist

# Generate report
npx selfopt-cli scan ./dist -o report.json
npx selfopt-cli report report.json -f markdown

# Compare for regressions
npx selfopt-cli compare baseline.json current.json

Configuration

initSelfOpt({
  mode: 'detect',        // 'detect' | 'optimize'
  debug: false,
  observers: {
    performance: true,
    errors: true,
    resources: true,
    layout: true,
  },
  optimizers: {
    images: true,        // lazy loading
    fonts: true,         // preload hints
    scripts: true,       // preconnect
    preconnect: true,
  },
  seo: true,
  storage: {
    persist: false,
    prefix: 'selfopt',
  },
});

What It Detects

| Category | Signals | |----------|---------| | Performance | LCP, CLS, INP, FCP, TTFB degradation | | Stability | JS errors, unhandled rejections | | Resources | Failed loads, broken links, third-party failures | | Layout | Layout shifts, images without dimensions | | SEO | Missing title, meta description, alt text, Open Graph |

What It Optimizes (in optimize mode)

| Optimization | Safety | |--------------|--------| | Image lazy loading | ✅ Safe — only below-fold images | | Font preload hints | ✅ Safe — adds resource hints | | Preconnect hints | ✅ Safe — adds connection hints | | Script defer warnings | ⚠️ Detection only — no runtime changes |

Philosophy

Websites don't suddenly fail. They slowly decay.

This project exists to observe, explain, and gently prevent that decay — without hype, surveillance, or lock-in.

Development

# Install dependencies
npm install

# Build all packages
npm run build

# Run tests
npm test

License

MIT © 2024