GLightbox is a lightweight, pure JavaScript lightbox library designed for displaying various media types including images, videos (YouTube, Vimeo, self-hosted), iframes, and inline content. It is currently stable at version `3.3.1`, with an active beta release stream (`4.0.0-beta.x`) indicating ongoing development towards a new major version. The library is known for its small footprint (11KB gzipped), responsiveness across devices, and comprehensive feature set including gallery support, responsive images, keyboard and touch navigation, zoomable images, and a themeable API. It differentiates itself by being a feature-rich solution without external dependencies, offering a complete lightbox experience out-of-the-box, making it a robust choice for modern web projects requiring media presentation. While minor bug fixes and improvements are released frequently for the v3 branch, the v4 branch represents a significant refactor and enhancement effort.
npm install glightboxVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a basic image and video gallery using GLightbox by including its CSS and JavaScript files from a CDN, and initializing it with a simple configuration. It showcases linking media with `<a>` tags and using `data-gallery` for grouping, and `data-glightbox` for inline titles/descriptions.
Review the official GLightbox v4 migration guide (when available) before attempting to upgrade. For production, consider staying on the stable `v3.x` branch until `v4.0.0` is officially released.
Always link `glightbox.min.css` in your HTML `<head>` or import it into your main CSS/SCSS file if using a bundler (e.g., `import 'glightbox/dist/css/glightbox.min.css';`).
Verify that the `selector` string passed to `GLightbox()` matches the CSS class or attribute of your `<a>` tags. For example, if your links have `class="my-lightbox-item"`, initialize with `GLightbox({ selector: '.my-lightbox-item' });`Ensure `glightbox.min.js` is linked via a `<script>` tag in your HTML (preferably at the end of `<body>`), or properly imported via ESM/CommonJS if using a module bundler. If using a script tag, make sure your initialization script runs after `glightbox.min.js` has loaded.
Double-check the `href` attribute of your `<a>` tag. For external content, ensure it's publicly accessible. If linking to URLs without clear file extensions (e.g., a dynamic image URL or a generic API endpoint), explicitly set the `data-type` attribute (e.g., `data-type="image"` or `data-type="video"`) on the `<a>` tag.
No dependency data recorded yet.