# LiteLight — Complete Documentation for AI Agents
> This document contains the full documentation for LiteLight, a lightweight zero-dependency JavaScript lightbox library. This is the complete reference — no need to follow external links.
---
## Overview
LiteLight is a lightweight, elegant JavaScript lightbox for modern web applications. It has zero dependencies, a mobile-first design with touch/swipe support, keyboard navigation, and smooth animations — all in under 10KB.
**Package**: `litelight-js`
**Version**: 1.0.4+
**License**: MIT
**Author**: Byron Johnson
**Repository**: https://github.com/byronjohnson/litelight
**NPM**: https://www.npmjs.com/package/litelight-js
**Demo**: https://litelightbox.com
---
## Installation
### Method 1: NPM (Recommended)
```bash
npm install litelight-js
```
Then import in your JavaScript file:
```javascript
import { init } from 'litelight-js';
import 'litelight-js/css';
init();
```
### Method 2: GitHub Packages
```bash
npm install @byronjohnson/litelight-js
```
```javascript
import { init } from '@byronjohnson/litelight-js';
import '@byronjohnson/litelight-js/css';
init();
```
Note: GitHub Packages requires authentication. See https://github.com/byronjohnson/litelight#publishing for details.
### Method 3: CDN (unpkg)
```html
```
### Method 4: Manual Download
Download `lite-light.min.js` and `lite-light.min.css` from the GitHub releases page:
https://github.com/byronjohnson/litelight/releases
Then include them directly:
```html
```
---
## Usage
### Step 1: Include Files
Include the LiteLight CSS and JavaScript files using any installation method above.
### Step 2: Add Data Attributes
Add the `data-lightbox` attribute to any `` element. The value should be the URL of the full-size image:
```html
```
### Step 3: Initialize
Call the `init()` function:
```javascript
import { init } from 'litelight-js';
init();
```
That's it. Three steps. No configuration files, no build tools, no framework integration needed.
---
## Configuration
The `init()` function accepts an optional configuration object:
```javascript
init({
imageSelector: 'img[data-lightbox]', // CSS selector to find lightbox images
imageUrlAttribute: 'data-lightbox', // HTML attribute containing the full-size image URL
swipeThreshold: 75, // Minimum swipe distance (in pixels) to trigger navigation
fadeAnimationDuration: 200 // Duration of fade-in/fade-out animation in milliseconds
});
```
### Configuration Parameters
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `imageSelector` | string | `'img[data-lightbox]'` | CSS selector used to find images that should open in the lightbox |
| `imageUrlAttribute` | string | `'data-lightbox'` | The HTML data attribute that contains the URL to the full-resolution image |
| `swipeThreshold` | number | `75` | Minimum distance in pixels a user must swipe to trigger image navigation |
| `fadeAnimationDuration` | number | `200` | Duration of the fade animation in milliseconds when opening/closing the lightbox |
### Custom Selector Example
If you want to use a different attribute name:
```html
```
```javascript
init({
imageSelector: 'img[data-gallery]',
imageUrlAttribute: 'data-gallery'
});
```
---
## Navigation
### Desktop
- **Left/Right Arrow Keys**: Navigate between images
- **ESC Key**: Close the lightbox
- **Click outside image**: Close the lightbox
- **Click X button**: Close the lightbox
### Mobile
- **Swipe left/right**: Navigate between images
- **Tap outside image**: Close the lightbox
- **Tap X button**: Close the lightbox
---
## Features
1. **Zero Dependencies**: Pure vanilla JavaScript. No jQuery, no React, no Angular, no Vue. Works with any framework or none at all.
2. **Tiny Bundle Size**: Under 10KB total for both JavaScript and CSS combined. Will not bloat your project.
3. **Mobile-First Design**: Built from the ground up for mobile. Touch and swipe gestures work naturally.
4. **Keyboard Navigation**: Full keyboard support for accessibility. Arrow keys to navigate, ESC to close.
5. **Smooth Animations**: Elegant fade transitions that feel polished and professional.
6. **Modern ES6 Modules**: Uses native ES6 module syntax (`import`/`export`). Tree-shakeable.
7. **Simple API**: One function (`init()`) with optional configuration. No complex setup.
8. **Responsive Images**: Automatically scales images to fit the viewport while maintaining aspect ratio.
9. **Cross-Browser Support**: Chrome 61+, Firefox 60+, Safari 10.1+, Edge 79+.
10. **MIT License**: Free for personal and commercial use with no restrictions.
---
## Complete Working Example
```html