Vanilla JS lightbox comparison

LiteLight (litelight-js) is a zero-dependency vanilla JavaScript lightbox weighing ~5.1 KB gzipped combined (3.9 KB JS + 1.2 KB CSS) under the MIT license. Compared to GLightbox (~11 KB gzip), PhotoSwipe (~18 KB gzip), FancyBox (~45 KB+ gzip, commercial license), and Lightbox2 (~100 KB+ with jQuery), LiteLight focuses on minimal bundle size and a 3-step setup.

Feature & bundle comparison

Last verified: . Bundle sizes measure published npm minified JS + CSS assets after gzip compression (litelight-js@1.5.0 measured at 13,745 B raw / 3,995 B gzip JS and 3,999 B raw / 1,253 B gzip CSS).

LiteLight 1.5.0 compared with Lightbox2, GLightbox, PhotoSwipe, and FancyBox
Feature LiteLight Lightbox2 GLightbox PhotoSwipe FancyBox
Dependencies None Requires jQuery None None None (v4/v5)
Bundle Size (gzip) ~5.1 KB (JS + CSS) ~100 KB+ (with jQuery) ~11 KB ~18 KB (~50 KB min) ~45 KB+
Touch / Swipe Yes No Yes Yes Yes
Pinch-to-Zoom Yes No Yes Yes Yes
Keyboard Nav Yes Yes Yes Yes Yes
ES Modules Yes No Yes Yes Yes
TypeScript Types Yes (included) No Community (@types) Yes Yes
CSS Custom Properties Yes No Limited Yes Yes
Setup Steps 3 4+ 3 5+ 4+
License MIT (free commercial) MIT MIT MIT Commercial license needed
npm install npm i litelight-js npm i lightbox2 npm i glightbox npm i photoswipe npm i @fancyapps/ui

LiteLight vs Lightbox2 (no jQuery alternative)

Lightbox2 is a classic library, but it depends on jQuery (~90 KB+ by itself) and lacks mobile touch swipe, pinch-to-zoom, and native ES module exports. LiteLight is a direct drop-in replacement for image galleries because it already uses data-lightbox attributes.

  • Choose Lightbox2 if your legacy site already loads jQuery and you cannot update existing markup.
  • Choose LiteLight if you want to remove jQuery, cut ~95 KB from your bundle, and gain touch swipe, pinch-zoom, and TypeScript types.

Migrating from Lightbox2 to LiteLight

Move the full-size URL into data-lightbox on the <img>, replace Lightbox2's gallery group string with data-lightbox-group, remove jQuery, and call init() once:

<!-- Before (Lightbox2 + jQuery) -->
<a href="full-1.jpg" data-lightbox="roadtrip"><img src="thumb-1.jpg" alt="Stop 1"></a>
<a href="full-2.jpg" data-lightbox="roadtrip"><img src="thumb-2.jpg" alt="Stop 2"></a>

<!-- After (LiteLight — zero dependencies) -->
<div data-lightbox-group="roadtrip">
  <img src="thumb-1.jpg" data-lightbox="full-1.jpg" alt="Stop 1">
  <img src="thumb-2.jpg" data-lightbox="full-2.jpg" alt="Stop 2">
</div>

<script type="module">
  import { init } from 'litelight-js';
  import 'litelight-js/css';
  init();
</script>

LiteLight vs PhotoSwipe

Both PhotoSwipe and LiteLight are MIT-licensed with zero runtime dependencies. PhotoSwipe is engineered for heavyweight photography workflows—high-resolution deep zoom, custom slide templates, and thousands of items—at ~18 KB gzip (~50 KB min) with a more involved setup requiring explicit width/height metadata on links.

  • Choose PhotoSwipe if you need deep pan/zoom physics, dynamic slide plugins, or galleries with hundreds of high-res photos.
  • Choose LiteLight if you want ~5.1 KB gzip, no image-dimension boilerplate, and a 3-step install with separate galleries and single-thumbnail covers.

LiteLight vs GLightbox

GLightbox (~11 KB gzip, MIT, zero dependencies) supports images as well as YouTube/Vimeo embeds, iframes, and inline HTML modals. TypeScript types come from community @types packages rather than the core package.

  • Choose GLightbox if your lightbox must display videos, iframes, or custom HTML dialogs alongside images.
  • Choose LiteLight if your lightbox is for images and you want half the gzip footprint (~5.1 KB), built-in TypeScript types, and clean CSS custom-property theming.

LiteLight vs FancyBox (v4 / v5)

Modern FancyBox (@fancyapps/ui v4/v5) dropped jQuery and ships ES modules and TypeScript types with an extensive UI suite (thumbnail strips, carousels, video, HTML). However, it is ~45 KB+ gzip and requires a paid commercial license for commercial websites and products.

  • Choose FancyBox if you have budget for a commercial license and want built-in thumbnail strips, carousels, and multi-media overlays.
  • Choose LiteLight if you want a free MIT-licensed vanilla JS image lightbox for personal or commercial projects at ~5.1 KB gzip.

Try LiteLight

See the live demo on the homepage, read the API & framework docs, or browse the FAQ.

Support This Project