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

hexo-imagesize-intrinsic

v1.0.5

Published

Hexo filter: embed intrinsic width/height for remote <img> at build time to reduce CLS.

Readme

hexo-imagesize-intrinsic

A Hexo plugin that writes intrinsic width/height attributes for remote <img> tags at build time.
This reduces Cumulative Layout Shift (CLS) and improves visual stability.

Example

Before (raw post content):

<p>
  <img src="https://cdn.example.com/example.png" alt="Demo image">
</p>

The image has no intrinsic size. When the browser loads, the layout may jump (CLS).

After (generated HTML by Hexo):

<p>
  <img src="https://cdn.example.com/example.png" alt="Demo image" width="1280" height="720">
</p>

The plugin probed the remote image, detected its intrinsic size (1280x720), and wrote width/height attributes into the <img>.

👉 Result: The page reserves space before the image is loaded, avoiding layout shift.

Features

  • ✅ Automatically detects remote images in posts/pages (layout: post or page)
  • ✅ Writes intrinsic width and height attributes into <img>
  • ✅ Supports non-ASCII filenames (Chinese, spaces, etc.)
  • ✅ Caches probed sizes in .cache/hexo-imgsize.json
  • ✅ Writes per-run report .cache/imgsize-run-report.json (grouped by page, with url/status/reason)
  • ✅ Configurable concurrency, timeout, retry, headers, referer
  • ✅ Optional progress bar (on stderr)
  • ✅ Three log levels: off | summary | verbose
  • ✅ Optional cache cleanup (remove unused or TTL-expired entries)

Install

npm install hexo-imagesize-intrinsic --save

Hexo will automatically load it.

Configuration

Minimal setup

In your site _config.yml, add:

imagesize_intrinsic:
  enabled: true
  log_level: summary   # off | summary | verbose
  progress: true       # show progress bar

This is usually enough for most sites.

Advanced options

| Option | Default | Description | |---------------------------|-----------|-----------------------------------------------------------------------------| | enabled | true | Master switch for the plugin | | log_level | summary | off = no logs; summary = only totals; verbose = per page & per image | | progress | true | Show progress bar on stderr | | concurrency | 8 | Number of concurrent probes (increase for faster builds if network allows) | | timeout_ms | 8000 | Timeout for each probe in milliseconds | | retry | 1 | Retry count after a failed probe | | strip_query | false | Drop ?query part of URL when caching size (useful if query doesn’t change pixels) | | referer | "" | Optional Referer header for anti-hotlinking hosts | | headers | {} | Extra request headers (merged with defaults) | | whitelist | [] | List of hostnames to process; empty = all remote images | | cache_present_with_size | true | Cache images that already have width/height, so other pages can reuse | | cleanup_unused | false | Enable cache cleanup after generate; when true, removes unused or expired entries | | cleanup_ttl_days | 0 | TTL for cache entries in days; > 0 removes entries not seen within TTL; 0 removes entries unused in the current run |

Output

  • Cache file: .cache/hexo-imgsize.json Stores probed sizes for reuse across builds.

  • Run report: .cache/imgsize-run-report.json Example:

    {
    "pages": [
        {
        "page": "posts/hello-world.md",
        "images": [
            {"url":"https://cdn.example.com/a.png","status":"wrote"},
            {"url":"https://cdn.example.com/b.png","status":"cached"},
            {"url":"https://cdn.example.com/c.png","status":"failed","reason":"timeout"},
            {"url":"https://cdn.example.com/d.png","status":"skipped","reason":"already-has-size"}
        ]
        }
    ]
    }
  • Logs:

    • summary → only final two lines:

    [imgsize] [total] pages=23 imgs=157 wrote=100 cached=50 failed=5 skipped=2 cleaned=12 [imgsize] run report -> .cache/imgsize-run-report.json ```

    • verbose → per-page + per-image detail.

Notes

  • If your site already has a large number of images, the first run may take a long time because all image sizes need to be probed. Subsequent runs will be much faster thanks to the cache in .cache/hexo-imgsize.json.
  • Works only for remote images (http/https). Local source/ images are skipped.
  • Progress bar prints to stderr; Hexo’s INFO logs remain in stdout.
  • If you had a theme script doing similar work, remove it to avoid duplication.
  • You can increase concurrency (e.g. 12–16) to speed up builds, depending on your network and image host.
  • timeout_ms and retry can be tuned for stability.
  • Cache stores a last_seen timestamp per URL; when cleanup_unused is enabled, cleanup runs in Hexo’s after_generate phase using cleanup_ttl_days (TTL-based) or current-run usage (TTL = 0).

License

MIT © Keldos Li