Convert Figma logo to code with AI

dimsemenov logoMagnific-Popup

Light and responsive lightbox script with focus on performance.

11,386
3,493
11,386
673

Top Related Projects

jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.

Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB – in total.

THE original Lightbox script (v2).

Full featured JavaScript image & video gallery. No dependencies

A touchable jQuery lightbox

Quick Overview

Magnific Popup is a responsive lightbox & dialog script with focus on performance and providing the best experience for users with any device. It's a fast, lightweight, and fully customizable lightbox plugin for jQuery and Zepto.js.

Pros

  • Lightweight and fast-loading, optimized for mobile devices
  • Highly customizable with many configuration options
  • Supports various content types (images, galleries, iframes, inline HTML)
  • Responsive and touch-friendly design

Cons

  • Requires jQuery or Zepto.js as a dependency
  • Limited built-in styling options, may require additional CSS for complex designs
  • Not actively maintained (last update was in 2016)
  • Some users report issues with certain browsers or specific use cases

Code Examples

  1. Basic image popup:
$('.image-link').magnificPopup({
  type: 'image'
});
  1. Gallery popup:
$('.gallery').magnificPopup({
  delegate: 'a',
  type: 'image',
  gallery: {
    enabled: true
  }
});
  1. Inline HTML popup:
$('.inline-popup-link').magnificPopup({
  type: 'inline',
  midClick: true
});
  1. Ajax popup:
$('.ajax-popup-link').magnificPopup({
  type: 'ajax'
});

Getting Started

  1. Include jQuery and Magnific Popup files in your HTML:
<link rel="stylesheet" href="magnific-popup/magnific-popup.css">
<script src="jquery.js"></script>
<script src="magnific-popup/jquery.magnific-popup.js"></script>
  1. Add your HTML markup:
<a href="image.jpg" class="image-popup">Open image</a>
  1. Initialize Magnific Popup in your JavaScript:
$(document).ready(function() {
  $('.image-popup').magnificPopup({
    type: 'image'
  });
});

This basic setup will create a lightbox popup for the linked image when clicked.

Competitor Comparisons

jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.

Pros of Fancybox

  • More feature-rich with advanced gallery options and animations
  • Better touch device support and mobile responsiveness
  • Actively maintained with frequent updates and improvements

Cons of Fancybox

  • Larger file size due to more features, potentially impacting page load times
  • Steeper learning curve for advanced customizations
  • Commercial license required for some use cases

Code Comparison

Magnific-Popup initialization:

$('.image-link').magnificPopup({
  type: 'image'
});

Fancybox initialization:

Fancybox.bind("[data-fancybox]", {
  // Options
});

Both libraries offer simple initialization, but Fancybox's newer versions use a more modern approach without jQuery dependency.

Magnific-Popup focuses on simplicity and performance, making it ideal for basic lightbox needs. Fancybox offers more advanced features and better mobile support, but comes with a larger footprint and potential licensing costs for commercial use. The choice between them depends on project requirements, performance considerations, and budget constraints.

Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB – in total.

Pros of Featherlight

  • Lightweight and simple to use, with minimal dependencies
  • Responsive design out of the box
  • Easy customization through CSS and JavaScript

Cons of Featherlight

  • Less feature-rich compared to Magnific-Popup
  • Limited built-in gallery functionality
  • Smaller community and fewer updates

Code Comparison

Featherlight:

$.featherlight('#myContent');

Magnific-Popup:

$.magnificPopup.open({
  items: {
    src: '#myContent'
  },
  type: 'inline'
});

Both libraries offer simple ways to create lightboxes, but Magnific-Popup provides more configuration options out of the box. Featherlight's approach is more minimalistic, which can be an advantage for simpler use cases.

Featherlight focuses on being lightweight and easy to use, making it a good choice for projects that require basic lightbox functionality without the need for extensive customization. On the other hand, Magnific-Popup offers a wider range of features and options, making it more suitable for complex implementations and gallery-style presentations.

While Magnific-Popup has a larger community and more frequent updates, Featherlight's simplicity can be an advantage for developers who prefer a more straightforward solution with less overhead.

THE original Lightbox script (v2).

Pros of Lightbox2

  • Simpler and more lightweight, making it easier to implement for basic image gallery needs
  • Better browser compatibility, supporting older versions of Internet Explorer
  • Includes built-in responsive design features

Cons of Lightbox2

  • Less feature-rich compared to Magnific-Popup, with fewer customization options
  • Limited support for content types other than images
  • Less active development and community support

Code Comparison

Lightbox2 initialization:

lightbox.option({
  'resizeDuration': 200,
  'wrapAround': true
});

Magnific-Popup initialization:

$('.image-link').magnificPopup({
  type: 'image',
  gallery: {
    enabled: true
  }
});

Both libraries offer simple initialization, but Magnific-Popup provides more advanced options for customization and content types. Lightbox2 focuses primarily on image galleries, while Magnific-Popup supports various content types and offers more flexibility in terms of styling and functionality.

Full featured JavaScript image & video gallery. No dependencies

Pros of lightgallery.js

  • More feature-rich, including video support and thumbnails
  • Better mobile touch support and responsive design
  • Actively maintained with frequent updates

Cons of lightgallery.js

  • Larger file size, which may impact page load times
  • Steeper learning curve due to more options and complexity
  • Less flexible for non-gallery use cases (e.g., modals, forms)

Code Comparison

Magnific-Popup initialization:

$('.gallery').magnificPopup({
  type: 'image',
  gallery: {
    enabled: true
  }
});

lightgallery.js initialization:

lightGallery(document.getElementById('lightgallery'), {
  thumbnail: true,
  animateThumb: false,
  showThumbByDefault: false
});

Both libraries offer simple initialization, but lightgallery.js provides more options for customization out of the box. Magnific-Popup's syntax is more jQuery-centric, while lightgallery.js uses vanilla JavaScript, making it more flexible for different project setups.

lightgallery.js excels in creating feature-rich, responsive image galleries with advanced functionality. However, this comes at the cost of a larger file size and potentially more complex setup. Magnific-Popup, while less feature-rich, offers a lighter-weight solution that's easier to implement for simple use cases and non-gallery popups.

A touchable jQuery lightbox

Pros of Swipebox

  • Lightweight and simple to implement
  • Touch-enabled with swipe gestures for mobile devices
  • Responsive design that works well on various screen sizes

Cons of Swipebox

  • Less feature-rich compared to Magnific-Popup
  • Limited customization options
  • Less frequent updates and maintenance

Code Comparison

Swipebox initialization:

$(document).ready(function() {
  $('.swipebox').swipebox();
});

Magnific-Popup initialization:

$(document).ready(function() {
  $('.image-link').magnificPopup({
    type: 'image',
    gallery: {enabled: true}
  });
});

Both libraries offer simple initialization, but Magnific-Popup provides more options for customization out of the box. Swipebox focuses on simplicity and touch-friendly interactions, while Magnific-Popup offers a wider range of features and configuration options.

Swipebox is ideal for projects that require a straightforward, mobile-friendly lightbox solution with minimal setup. Magnific-Popup is better suited for more complex projects that need advanced features, extensive customization, and regular updates.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Important note This jQuery plugin is deprecated, only critical or security bug fixes will be released in future. Use native <dialog> element if you need a basic dialog/modal/popup, or my PhotoSwipe library if you need an advanced image gallery. Feel free to email me if you need assistance.

Stand With Ukraine

Magnific Popup Repository

Build Status

Fast, light and responsive lightbox plugin, for jQuery and Zepto.js.

Optionally, install via Bower bower install magnific-popup or npm: npm install magnific-popup. Ruby gem: gem install magnific-popup-rails.

Extensions

If you created an extension for some CMS, email me and I'll add it to this list.

Location of stuff

  • Generated popup JS and CSS files are in folder dist/. (Online build tool is on documentation page).
  • Source files are in folder src/. They include Sass CSS file and js parts (edit them if you wish to submit commit).
  • Website (examples & documentation) is in folder website/.
  • Documentation page itself is in website/documentation.md (contributions to it are very welcome).

Using Magnific Popup?

If you used Magnific Popup in some interesting way, or on site of popular brand, I'd be very grateful if you email me a link to it.

Build

To compile Magnific Popup by yourself, first of make sure that you have Node.js, Grunt.js, Ruby and Jekyll installed, then:

  1. Copy repository

    git clone https://github.com/dimsemenov/Magnific-Popup.git

  2. Go inside Magnific Popup folder that you fetched and install Node dependencies

    cd Magnific-Popup && npm install

  3. Now simply run grunt to generate JS and CSS in folder dist and site in folder _site/.

    grunt

Optionally:

  • Run grunt watch to automatically rebuild script when you change files in src/ or in website/.
  • If you don't have and don't want to install Jekyll, run grunt nosite to just build JS and CSS files related to popup in dist/.

Changelog

License

Script is MIT licensed and free and will always be kept this way. But has a small restriction from me - please do not create public WordPress plugin based on it(or at least contact me before creating it), because I will make it and it'll be open source too (want to get notified?).

Created by @dimsemenov & contributors.

Bitdeli Badge

Bugs & contributing

Please report bugs via GitHub and ask general questions through Stack Overflow. Feel free to submit commit pull-request, even the tiniest contributions to the script or to the documentation are very welcome.

NPM DownloadsLast 30 Days