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

justified-gallery

v4.0.2

Published

Justified Gallery is a JavaScript library that allows you to create an high quality justified gallery of images.

Readme

npm version license

open issues closed issues unit tests e2e tests

GitHub stars total downloads

(combined across justified-gallery and legacy justifiedGallery npm packages)

Usage

import { JustifiedGallery } from "justified-gallery";
import "justified-gallery/style.css";

const gallery = document.getElementById("gallery");
const jg = new JustifiedGallery(gallery);
jg.init();

// later, on unmount:
jg.destroy();

JustifiedGallery is a plain class working against a real HTMLElement, so it integrates the same way in any framework: get a ref to the container, call init() once it's mounted, and call destroy() on cleanup. See test/browser/html/react_gallery.tsx and test/browser/html/vue_gallery.vue for working React and Vue examples.

The stylesheet keeps entries hidden until they're positioned, so you don't see a flash of raw, unpositioned images. This only applies inside a container with the justified-gallery class, since that's what the CSS targets:

.justified-gallery > a,
.justified-gallery > div,
.justified-gallery > figure {
  opacity: 0;
  /* ... */
}

init() adds that class for you, but not until your script runs. So the hiding won't actually happen before then unless you also add the class yourself, directly in your markup:

<div id="gallery" class="justified-gallery">...</div>

init() adding the class again is harmless; destroy() still removes it.

This also depends on the CSS itself being loaded before your script runs. The import "justified-gallery/style.css" above takes care of that for bundler setups (bundlers usually put CSS imports into a <link> that loads ahead of your JS). If you're loading the library from a plain <script> tag or CDN with no build step, link the stylesheet the same way, directly in <head>, before your script tag:

<link
  rel="stylesheet"
  href="https://.../justified-gallery/dist/assets/justified-gallery.css"
/>

Contributing

  • Prerequisites:

    • Node.js
    • npm install to install all dependencies.
  • Develop:

    • npm run dev starts a Vite dev server against test/browser, serving the source directly (no build step needed while iterating). In this mode /text/browser/html pages can be explored. These are the same pages used by the e2e tests.
  • Build:

    • npm run build compiles the library for distribution: bundles src/justified-gallery.ts with Vite into dist/justified-gallery.js and dist/assets/justified-gallery.css, and emits type declarations (dist/*.d.ts) with tsc.
    • npm run preview serves the built dist output locally.
  • Test:

    • npm test runs the full suite (unit tests, then browser/e2e tests).
    • npm run test:unit runs the Vitest unit tests in test/unit.
    • npm run test:e2e runs the Playwright browser tests in test/browser.
  • Try the built package as a real npm dependency:

    • scripts/test-local-package.sh builds the library, npm links it, and links/serves it from sandbox-consumer/ (a throwaway, gitignored Vite project) — useful to confirm the published package resolves and works the way a downstream consumer would experience it.