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

@cabraham/react-smart-loader

v1.1.0

Published

Smart, network-aware React image component: lazy loading, blur/shimmer placeholders, exponential-backoff retry, and zero-CLS transitions in <4KB.

Readme

@cabraham/react-smart-loader

Smart, network-aware React image component in < 2KB gzipped with zero dependencies.

Lazy loading, blur / shimmer placeholders, exponential-backoff retry, zero-CLS cross-fade transitions, and a global memory cache — all behind a single <SmartImage> component that extends the native <img> API.

Install

npm install @cabraham/react-smart-loader

react and react-dom (>= 18) are peer dependencies. React 19's resource loading (ReactDOM.preload) is used automatically when available.

Usage

import { SmartImage } from '@cabraham/react-smart-loader';

<SmartImage
  src="https://cdn.example.com/hd-product.jpg"
  aspectRatio={16 / 9}
  placeholder="blur"
  blurSource="data:image/png;base64,iVBOR..." // base64, micro-URL, or decoded hash
  priority={false}
  fallbackSrc="/images/fallback-placeholder.png"
  alt="Product photo"
/>

Because SmartImageProps extends React.ImgHTMLAttributes<HTMLImageElement>, every native attribute (alt, className, style, aria-*, onClick, …) just works.

Props

| Prop | Type | Default | Notes | | --- | --- | --- | --- | | src | string | — | High-res source. | | aspectRatio | number | — | e.g. 16 / 9. Reserves space → zero CLS. | | placeholder | 'blur' \| 'shimmer' \| 'none' | 'blur' | Shown until decode. | | blurSource | string | — | base64 / micro-URL / decoded hash. | | priority | boolean | false | Eager load + high fetchPriority (+ React 19 preload). | | preloadNext | string[] | — | Warm neighbours after load (carousels). | | fallbackSrc | string | — | Used after retries are exhausted. | | maxRetries | number | 3 | Backoff: 1s, 2s, 4s. | | networkAware | boolean | true | Degrade on Save-Data / 2G-3G. | | onLoaded / onErrorFinal | () => void | — | Lifecycle callbacks. |

Placeholders

The base component accepts any string in blurSource. To decode a compact hash into a placeholder, import the matching separate entry point — this keeps the decoder out of the base bundle unless you use it:

import { blurHashToDataURL } from '@cabraham/react-smart-loader/blurhash';

const blur = blurHashToDataURL('LGF5?M9F00~q_MOffQWB00%MwbRj', 32, 32);
// → pass to <SmartImage blurSource={blur} />

ThumbHash

@cabraham/react-smart-loader/thumbhash exposes the final API surface, but the decode body is not yet implemented (see src/thumbhash.ts). It throws until a decode strategy is chosen — use @cabraham/react-smart-loader/blurhash or a plain base64/micro-URL in the meantime.

Predictive preloading

Beyond the preloadNext prop (warmed on hover), usePredictivePreload watches scroll velocity and warms upcoming images before they enter the viewport:

import { usePredictivePreload } from '@cabraham/react-smart-loader';

const upcoming = items.map((i) => i.imageUrl);
usePredictivePreload(upcoming, { count: 2, velocityThreshold: 0.4 });

Demo

A live demo lives in demo/ and runs against the package source (no build step — edit src/* and it hot-reloads):

cd demo
npm install
npm run dev   # http://localhost:5173

Development

npm install
npm run build      # tsup → dist (ESM + CJS + .d.ts)
npm test           # vitest
npm run size       # size-limit budget check
npm run typecheck  # tsc --noEmit

Bundle size

| Entry | Gzipped | Ships when | | --- | --- | --- | | @cabraham/react-smart-loader | ~1.7 KB | always | | @cabraham/react-smart-loader/blurhash | ~1.0 KB | imported | | @cabraham/react-smart-loader/thumbhash | ~0.4 KB | imported |

ESM + CJS, full TypeScript types, "sideEffects": false for tree-shaking.

License

MIT © Abraham Christopher