LiteLight

The simplest vanilla JavaScript lightbox with zero dependencies

Get it at

How to Use This Simple Vanilla JavaScript Lightbox

  • Click on any image to open it in the zero-dependency lightbox
  • Arrow keys (← →) to navigate between images - pure JavaScript navigation
  • Swipe left/right on mobile devices to navigate (vanilla JS touch events)
  • ESC key or click outside the image to close the simple lightbox
  • Click the X button to close the vanilla JavaScript modal

Simple 3-Step Implementation

Why choose our vanilla JavaScript lightbox? Zero dependencies, minimal code, maximum performance. Perfect for developers who want simple, clean solutions.

Step 1: Install and Include

Install via npm (no external dependencies required):

npm install litelight-js

Then import in your JavaScript:

<script type="module">
  import { init } from 'litelight-js';
  import 'litelight-js/css';
  init();
</script>

Traditional Implementation (Optional)

If you prefer using direct file links without npm, download the files from GitHub:

<!-- In your <head> -->
<link rel="stylesheet" href="path/to/lite-light.min.css">

<!-- Before closing </body> -->
<script type="module">
  import { init } from './path/to/lite-light.min.js';
  init();
</script>

Note: Download the dist/lite-light.min.css and dist/lite-light.min.js files from the repository and place them in your project directory.

Step 2: Add Data Attributes

Add the data-lightbox attribute to any image with the URL of the high-resolution version:

<img src="thumbnail.jpg" data-lightbox="full-size.jpg" alt="Description">

Step 3: You're Done!

That's it! Your simple vanilla JavaScript lightbox is ready. No jQuery, no frameworks, just pure JavaScript magic.

Why Vanilla JavaScript?

  • ✓ Faster loading - no framework overhead
  • ✓ Smaller bundle size - under 10KB total
  • ✓ Better performance - optimized vanilla JS
  • ✓ Future-proof - no dependency updates needed
  • ✓ Universal compatibility - works everywhere