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

@handy-ones/handy-lazy-img

v1.0.0

Published

React component for intelligent image lazy-loading with IntersectionObserver API. Features responsive images (srcset) and layout shift prevention. [Demo](https://ivliag.github.io/handy-ones/?story=handy-lazy-img--basic)

Readme

HandyLazyImg

React component for intelligent image lazy-loading with IntersectionObserver API. Features responsive images (srcset) and layout shift prevention. Demo

Usage

Install it from npm

npm i @handy-ones/handy-lazy-img

Basic lazy-loaded image

import {HandyLazyImg} from '@handy-ones/handy-lazy-img';

export const LazyImage = () => (
    <HandyLazyImg
        src="https://example.com/image.jpg"
        alt="Description of image"
        width={800}
        height={600}
    />
)

Responsive images with srcSet

import {HandyLazyImg} from '@handy-ones/handy-lazy-img';

export const ResponsiveImage = () => (
    <HandyLazyImg
        src="https://example.com/image-800.jpg"
        alt="Description of image"
        srcSet={[
            {src: 'https://example.com/image-400.jpg', width: 400},
            {src: 'https://example.com/image-800.jpg', width: 800},
            {src: 'https://example.com/image-1200.jpg', width: 1200}
        ]}
        width={800}
        height={600}
    />
)

Prevent layout shift with aspect ratio

import {HandyLazyImg} from '@handy-ones/handy-lazy-img';

export const FixedAspectRatio = () => (
    <HandyLazyImg
        src="https://example.com/image.jpg"
        alt="Description of image"
        aspectRatio={16 / 9}
        style={{width: '100%'}}
    />
)

Error handling

import {HandyLazyImg} from '@handy-ones/handy-lazy-img';

export const ImageWithErrorHandling = () => (
    <HandyLazyImg
        src="https://example.com/image.jpg"
        alt="Description of image"
        onError={(error) => console.error('Image failed to load:', error)}
        onLoad={(event) => console.log('Image loaded successfully')}
    />
)

Demo

Please click </> button to see the demo source code:

  1. Basic usage
  2. Responsive images
  3. Aspect ratio
  4. Error handling
  5. Multiple images

API

Props

interface HandyLazyImgProps extends React.ImgHTMLAttributes<HTMLImageElement> {
    src: string; // Image source URL (required)
    alt: string; // Alt text for accessibility (required)
    threshold?: number; // IntersectionObserver threshold (default: 0.1)
    rootMargin?: string; // IntersectionObserver root margin (default: '50px')
    srcSet?: ImageSource[]; // Array of {src, width} for responsive images
    aspectRatio?: number; // Aspect ratio (width/height) to prevent layout shift
    onLoad?: (event: Event) => void; // Callback when image loads successfully
    onError?: (error: Error) => void; // Callback when image fails to load
    className?: string; // Additional CSS class name
    width?: number; // Image width
    height?: number; // Image height
}

interface ImageSource {
    src: string; // Image URL
    width: number; // Image width descriptor
}

License

MIT