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

@page-speed/img

v0.4.6

Published

Performance-optimized React Image component. Drop-in image implementation of web.dev best practices with zero configuration.

Readme

⚡ @page-speed/img

Page Speed React Image Component

Performance-optimized React Image component

Drop-in Image implementation of web.dev best practices with zero configuration. Also a great alternative to next/image for non-Next.js projects that still need the automated image optimization tools that the Next Image component provides.

npm version npm downloads License TypeScript Tree-Shakeable

Documentation · Quick Start · Hooks · Examples · Contributing


Documentation

@page-speed/img is a React-first, OptixFlow-enabled image component that ships Lighthouse-friendly markup by default. It uses useOptimizedImage from @page-speed/hooks to compute pixel-perfect src, DPR-aware srcset, and sizes on the client. Tree shaking keeps the bundle lean—only the media hook is pulled in.

Installation

pnpm add @page-speed/img

Peer deps: react and react-dom (17+). For OptixFlow optimization, supply an API key.

Usage (React / Next.js)

import { Img, setDefaultOptixFlowConfig } from "@page-speed/img";

// Optional: set once at app start
setDefaultOptixFlowConfig({ apiKey: process.env.NEXT_PUBLIC_OPTIX_API_KEY!, compressionLevel: 80 });

export function HeroImage() {
  return (
    <Img
      src="https://images.example.com/hero.jpg"
      alt="Hero"
      width={1280}
      height={720}
      // Per-image override (optional)
      optixFlowConfig={{ renderedFileType: "jpeg", objectFit: "cover" }}
    />
  );
}

What you get:

  • Pixel-perfect primary src sized to the rendered element (Lighthouse “Properly size images” pass).
  • DPR-aware srcset (1x/2x) for AVIF/WebP/JPEG.
  • Lazy loading with IntersectionObserver; set eager for above-the-fold.
  • Optional OptixFlow compression/format selection with a single prop.

Props

  • src (string, required): Image URL.
  • alt, title, standard <img> attributes.
  • width, height: Set for CLS prevention; used as hints for sizing. Actual rendered size is measured to generate the pixel-perfect URL.
  • loading, decoding: Defaults lazy / async. Set eager to force above-the-fold fetch.
  • sizes: Override the auto-generated sizes from useOptimizedImage.
  • intersectionMargin, intersectionThreshold: Tweak lazy-load observer.
  • optixFlowConfig: { apiKey: string; compressionLevel?: number; renderedFileType?: 'avif' | 'webp' | 'jpeg' | 'png'; objectFit?: 'cover' | 'contain' | 'fill'; }.

Global defaults (React & UMD)

  • Programmatic: setDefaultOptixFlowConfig({ apiKey: '...' }) once during app init.
  • Browser global (UMD/inline):
<script>
  window.PageSpeedImgDefaults = {
    optixFlowConfig: {
      apiKey: "YOUR_OPTIX_KEY",
      compressionLevel: 80,
      objectFit: "cover"
    }
  };
</script>

window.OpensiteImgDefaults and window.PAGE_SPEED_IMG_DEFAULTS are also honored for backward compatibility.

UMD usage

<script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
<script src="https://cdn.jsdelivr.net/npm/@page-speed/[email protected]/dist/browser/page-speed-img.umd.js" crossorigin></script>

<div id="app"></div>
<script>
  const root = ReactDOM.createRoot(document.getElementById('app'));
  root.render(
    React.createElement(PageSpeedImg.Img, {
      src: 'https://images.example.com/card.jpg',
      alt: 'Card',
      width: 800,
      height: 600,
      optixFlowConfig: { apiKey: 'YOUR_OPTIX_KEY', compressionLevel: 70 }
    })
  );
</script>

SSR considerations

  • The component is client-only ("use client"). For SSR apps, render it in client components/entry points.
  • Safe in non-browser contexts: guards exist for window/IntersectionObserver.

Tree shaking

@page-speed/img only imports useOptimizedImage from @page-speed/hooks, keeping bundles small. Both ESM and CJS builds are emitted; UMD is externalized to React/ReactDOM.

Testing

pnpm test

Roadmap

  • Add storybook examples for common layouts (hero, gallery, card).

Contributing

PRs welcome. Please run pnpm test before submitting.