A Lightweight Alternative to the Vanilla JS Lightbox | yBox

yBox is a lightweight and feature-rich lightbox JavaScript library for images, videos, iframes, text, and any HTML content out of the box.


Modern browsers such as Chrome, Firefox, and Safari have been tested on both desktop and smartphone devices.

Must Read: Modern Photo/Video Gallery and Lightbox Plugin | nanogallery2

How to make use of it:

1. Start by inserting the yBox’s JavaScript and CSS into the HTML document.

<link rel="stylesheet" href="dist/css/yBox.min.css" />
<script src="dist/js/yBox.min.js"></script>

2. Initialize the yBox library.

window.onload = function(){
    var myYbox = new yBox();

3. Show a lightbox when needed.

myYbox.yBox('Lightbox Content Here');

4. Load content from any component throughout the document.

<div style="display:none;">
  <div id="modalContent">
    Modal Content here
<a class="yBox" href="#modalContent">Launch The Lightbox</a>

5. Open an iframe within the lightbox. Ideal for Youtube videos.

<a href="https://www.youtube.com/watch?v=1" class="yBox yBox_iframe">
  Open The Youtube Video

6. Load content through AJAX.

<a href="https://www.google.com" class="yBox yBox_ajax">
  Launch The Lightbox

7. Apply a further CSS class to the lightbox.

<a class="yBox" data-popup-class="customClass" href="#modalContent">Launch The Lightbox</a>

8. Create a gallery lightbox from a bunch of photos.

<a href="1.jpg" class="yBox" data-ybox-group="group1">
  // Add Image Here
<a href="2.jpg" class="yBox" data-ybox-group="group1">
  // Add Image Here
<a href="3.jpg" class="yBox" data-ybox-group="group1">
  // Add Image Here

9. Event handlers.

myYbox.onYboxOpen = function(){
  // Fired when yBox is opened

myYbox.onYboxClose = function(){
  // fired when yBox is closed

myYbox.onNextItemClick = function(){
  // fired when clicking next button

myYbox.onPrevItemClick = function(){
  // fired when clicking prev button



See Demo And Download

Official Website(Leshemiko): Click Here

This superior jQuery/javascript plugin is developed by Leshemiko. For extra advanced usage, please go to the official website.

Related Posts


A Simple Searchable Select Dropdown Plugin | jQuery Select Search

Simple jQuery search on the selection options plugin for your website. Next, there is a checkbox replacement plugin that refines and beautifies the original selection element with…


A Quick jQuery-Based Country Picker With Flags | Country Select JS

Country Select JS is a jQuery plugin to select a country, based on the international phone input plugin. Adds a flag dropdown to any input, which lists…


Simple and Fast Autocomplete and Typeahead Javascript Library | autoComplete.js

autoComplete.js is a simple, pure, and incrementally designed JavaScript library for speed, high versatility, and seamless integration with a wide variety of projects and systems. Features Pure…


Bootstrap Notification Message Alert Plugin with jQuery

BootstrapMsg is a jQuery plugin for displaying messages with Bootstrap alert classes to generate hierarchical in-page navigation for an extended webpage sectioned by heading components. Using Bootstrap…


jQuery Plugin for Transforming HTML Tables Into Charts Using Google Charts

Chartinator is a jQuery plugin for converting HTML tables, Google Sheets and js arrays into charts using Google Charts. Use data from HTML tables Chartinator is designed…


Customizable & Composable Charts for VueJS | vue-wcharts

WCharts is a library that makes it easy to create your own charts using Vuejs. You can easily create reusable chart components. Use a basic layout or…

Leave a Reply

Your email address will not be published. Required fields are marked *