PhotoSwipe v5.4.4 is a highly customizable JavaScript image gallery and lightbox designed for touch devices. It supports common features like swiping, zooming, and pan gestures, and includes core and lightbox components for flexible integration. The library maintains an active release cadence, frequently publishing patch and minor versions to address bugs, enhance accessibility, and improve browser compatibility. Key differentiators include robust touch support, a modular architecture allowing for dynamic import of its core, extensive customization options via filters and options, and strong focus on accessibility (ARIA attributes, focus trapping) and offline functionality. It ships with TypeScript types, facilitating modern development workflows. It offers a significant rewrite compared to its v4 predecessor, focusing on modern web standards and modularity.
npm install photoswipeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to set up a basic PhotoSwipe gallery with multiple images using HTML data attributes and initialize the lightbox.
Refer to the official PhotoSwipe v5 documentation for migration guides and new API usage patterns.
Upgrade to PhotoSwipe v5.4.0 or newer. If stuck on an older version, ensure your build process transpiles to a compatible ES version for your target browsers.
Upgrade to v5.3.4 or later to benefit from improved accessibility. The `trapFocus` option was added in v5.4.1 for further control.
Upgrade to PhotoSwipe v5.3.6 or newer to resolve the `srcset` lazy-loading issue.
When using versions prior to 5.4.2, always provide a valid `dataSource` array or gallery index to `loadAndOpen`. For 5.4.2+, it defaults to the first gallery if not provided.
Ensure you are using `import PhotoSwipeLightbox from 'photoswipe/lightbox';` for ESM setups or loading the correct script files in the browser. Verify your bundler configuration if applicable.
Upgrade to PhotoSwipe v5.4.0 or newer, which includes fixes for these syntax issues. Alternatively, ensure your build pipeline transpiles modern JavaScript to an ES version supported by your target browsers.
Double-check that the `gallery` and `children` selectors accurately match your HTML structure. Ensure the `pswpModule` option is correctly set up as a dynamic import: `pswpModule: () => import('photoswipe')`.No dependency data recorded yet.