Slimbox 2, the ultimate lightweight Lightbox clone for jQuery

Version: 2.05
Category: jQuery Javascripts


Slimbox 2 is a 4 KB visual clone of the popular Lightbox 2 script by Lokesh Dhakar, written using the jQuery javascript library. It was designed to be very small, efficient, standards-friendly, fully customizable, more convenient and 100% compatible with the original Lightbox 2.


Single images

Gilles at BarvauxGates gets a pie

Image set

These are pictures I took during a journey through India and Nepal in 2008.


From a functional point of view, Slimbox 2 has the following added features compared to the original Lightbox:

From a design point of view, Slimbox 2 is very different from Lightbox:

Slimbox 2 is currently the smallest Lightbox-like script available for the jQuery library.


Slimbox 2 is compatible with all modern browsers: Firefox 2+, Internet Explorer 6+, Opera 9+ and Opera for Wii, Safari 3+, Camino and Google Chrome.

It works with both strict mode and quirks mode web pages.

Unlike many Lightbox-like scripts, it displays fine in case of horizontal scrolling of the web page.

It is disabled by default on mobile devices (Android, iPhone/iPod, Symbian, Windows Mobile, BlackBerry).

Note: there is a bug in Google Chrome versions 4 to 8 for Linux with many non-english locales, causing the overlay to stay invisible when Slimbox is opened. This bug does not affect other operating systems and was fixed since Chrome 9.


Slimbox 2.05 requires the jQuery library, version 1.3 or more recent. If you don’t already have it, you can download jQuery from its official website.


Usage is exactly the same as for Lightbox by default, but Slimbox 2 offers more options.

Because it was designed to be 100% compatible with Lightbox, you just need to replace the scripts combination “Prototype + Scriptaculous + Lightbox” with “jQuery + Slimbox 2” in the header of your pages and your Lightbox effects will work just as well as before. Well, a little better.


1. Include the script in the header of your page, after the inclusion of the jQuery library:

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/slimbox2.js"></script>

There are some options that you can specify in the form of a javascript object inside the script (look for “put custom options here”). The default values should be just fine, however if you want you can change the following:

Example of a custom options object, including french translation:

	overlayOpacity: 0.6,
	resizeEasing: "easeOutElastic",
	captionAnimationDuration: 1,
	counterText: "Image {x} sur {y}",
	closeKeys: [27, 70],
	nextKeys: [39, 83]

2. Include the CSS file in the header of your page, or add it to an existing CSS style sheet:

<link rel="stylesheet" href="css/slimbox2.css" type="text/css" media="screen" />

Or, if you are using a right-to-left language:

<link rel="stylesheet" href="css/slimbox2-rtl.css" type="text/css" media="screen" />

If you keep the provided CSS as is, you must place the 4 required images in the same folder as the CSS file. Of course you can change the images or move them to another place, then you just need to edit the CSS URLs (and the image width and height for the “Close” image) to reflect your changes. You don’t even need to edit the javascript.

You can also change the fonts for the caption and the image counter, the width of the border around the lightbox and the caption, the margins in the caption and every color. You must not add new CSS rules.


Add the rel="lightbox" attribute to the links pointing to your full-sized images. Use the optional title attribute if you want to show a caption:

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

You can even use HTML in the caption if you want. You must replace the < and > characters with HTML entities and use single quotes instead of double quotes.

For sets of related images that you want to group and make navigable, add a group name to the rel attribute just after the “lightbox” word, for example:

<a href="images/image-1.jpg" rel="lightbox-cats">image #1</a>
<a href="images/image-2.jpg" rel="lightbox-cats">image #2</a>
<a href="images/image-3.jpg" rel="lightbox-cats">image #3</a>

I don’t recommend using square brackets “[ ]” around group names in the rel attribute like the original Lightbox script does because these characters are invalid for XHTML and XML attributes, meaning that your web page would not validate against the latest standards.

API for Javascript programming

Additionally, Slimbox also allows you to:

Please read the complete API documentation to learn how to do this. The possibilities are limitless.


Slimbox is free software released under MIT License.
If you like it, talk about it and promote it by linking to this page.

Slimbox 2.05

Get Help

First, please read the FAQ.

If the answer of your question is not there, you can ask it on the Slimbox Google Group.

Please note that I distribute Slimbox “as is”, I don’t get any money for it, and therefore I have no time to do support for it and I won’t answer trivial questions.


v2.05 (2013-05-07)

v2.04 (2010-04-28)

v2.03 (2009-11-19)

v2.02 (2009-01-28)

v2.01 (2009-01-12)

v2.0 (2008-12-31)

Your opinion about this software?