On this page
Overview
PhotoSwipe is a JavaScript image gallery and lightbox for mobile and desktop. Its Core, Lightbox, and CSS are separated so thumbnail galleries can open large images with swipe and zoom interactions without requiring a frontend framework.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Split Lightbox and Core so the gallery engine can load on demand
The recommended setup lets PhotoSwipeLightbox watch gallery clicks and dynamically import Core through pswpModule, keeping the initial bundle smaller until the gallery is opened.
Sources: [2]
Use existing links and thumbnails as the gallery data source
Configure a ギャラリーcontainer and children selector, then provide the image URL plus data-pswp-width and data-pswp-height on each link. A thumbnail image can live inside the same link.
Sources: [2]
Build around レスポンシブ画像s and progressive enhancement
The official guide recommends レスポンシブ画像s and expects content to remain reachable through normal image links even when PhotoSwipe does not run.
Sources: [2]
Best fit
Before adoption
Every image needs known width and height before opening
PhotoSwipe requires image dimensions in advance and documents data-pswp-width and data-pswp-height on gallery links, so 動的content needs a dimension-metadata strategy.
Sources: [2]
Avoid serving extremely large source images directly
The guide says PhotoSwipe is not designed for very large images and recommends レスポンシブ画像s, with roughly 3000x3000px as the usual maximum recommendation unless a tiling approach is used.
Sources: [2]
Official sources
- [1]PhotoSwipe v5.4.4 README(2026-10-05)
- [2]PhotoSwipe v5.4.4 Getting Started(2026-10-05)
- [3]PhotoSwipe v5.4.4 package metadata(2026-10-05)
- [4]PhotoSwipe v5.4.4 release(2026-10-05)
- [5]PhotoSwipe MIT license(2026-10-05)
Supplemental curator note
PhotoSwipe's Core/Lightbox split allows the heavier Core module to be loaded only when the gallery opens. Because each image needs known width and height, CMS or API integrations should plan how those dimensions are stored and delivered.
Try it in 3 steps
- 1
Install PhotoSwipe 5.4.4
Pin the reviewed stable v5 release.
npm install --save-exact photoswipe@5.4.4 - 2
Create gallery markup with image dimensions
Provide the large image URL and required
data-pswp-widthanddata-pswp-heightattributes on each link.<div id="my-gallery"><a href="large.jpg" data-pswp-width="1600" data-pswp-height="1200"><img src="thumb.jpg" alt=""></a></div> - 3
Initialize PhotoSwipeLightbox
Let Lightbox dynamically load Core when needed and open gallery links in PhotoSwipe.
import PhotoSwipeLightbox from 'photoswipe/lightbox'; import 'photoswipe/style.css'; const lightbox = new PhotoSwipeLightbox({ gallery: '#my-gallery', children: 'a', pswpModule: () => import('photoswipe') }); lightbox.init();
Growth
Growth trends · Last 30 days
25,270 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 0
- Open PRs
- 8
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- gallery
- lightbox
- image
- javascript
- Stars
- 25,270
- Forks
- 3,271
- Watchers
- 521
- Open issues
- 162
- Contributors
- 70
- Owner type
- User
- Primary language
- JavaScript
- License
- MIT
- Repository last updated
- Dec 4, 2025
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Bootstrap174,991 Stars
4 shared tag(s)
Build responsive interfaces from a CSS/Sass grid, utilities, components, and native JavaScript
MDX - Storybook91,200 Stars
4 shared tag(s)
capture UI states once and reuse them across docs, interaction tests, and agent tooling
TypeScript - Expo52,566 Stars
4 shared tag(s)
build React Native apps for Android, iOS, and web from one project model
TypeScript - Alpine.js31,960 Stars
4 shared tag(s)
add state, events, and display behavior directly to HTML for small interactive interfaces
HTML - Uppy31,010 Stars
4 shared tag(s)
compose file-selection UI and resumable uploads from plugins across local and remote sources
TypeScript - flatpickr16,464 Stars
4 shared tag(s)
pick dates, times, ranges, and multiple days with a dependency-free UI and configurable disabled dates and locales
TypeScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.