PDA

View Full Version : Lightbox not working fast enough



purpleman
02-04-2007, 09:49 AM
1) Script Title:
Lightbox image Viewer 1.0

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex4/lightbox/index.htm

3) Describe problem:

I have placed the script on a page that loads 30 images on the page and I have them all going through the script. If I'm "quick on the trigger" and click the first lightboxed image, the script isn't kicking in and it just acts as a regular link and displays the image on a new page. Once the page is fully loaded, everything works as it should. It's just as the page is loading.

Is there anyways to reduce the delay of the script initializing or am I stuck with it? Does version 2 solve my problems?

Thanks.

Purpleman

jscheuer1
02-04-2007, 01:49 PM
Like my reply to your post about Ultimate Fade In slide show, look into image optimization to speed the loading of the page. Consider removing some of the images. 10 is a lot of images for any given page. Even with only 10 images, you would still have a problem like you describe though. Lightbox will not work until it initializes. Usually this is done onload of the page. I have not tested this but, you might be able to get it to initialize for each thumbnail like so:


<a href="large.jpg" rel="lightbox"><img src="small.jpg" onload="initLightbox();"></a>

Another way of doing this that might work better and that can be used with text triggers as well as for thumbnail image triggers is:


<a href="large.jpg" rel="lightbox"><img src="small.jpg"></a>
<script type="text/javascript">initLightbox();</script>


Whichever method you use, it would need to be done for each trigger.



To speed loading of the page in general - avoid nested tables and, make sure that all of the images used as thumbnail triggers (if any) are true thumbnails and are optimized.

Don't use the larger images themselves, as some folks do, relying upon the browser to visually scale them down to the dimensions of thumbnails. When they do that, it can take a long time to load each trigger.

Dave19
03-27-2008, 09:53 AM
Me too, I got the same prob as that of purpleman bt I hv only 6 thumb pics displayed on the page.

There might be a prob with the connection speed as well. (For e.g: having people using dial-up speed)

I will try to do as jscheuer1 suggested that is placing the method initlightbox for each pic.

Should I remove the following from lightbox.js file:


Event.observe(window,'load',function(){ Lightbox.initialize(); });

Dave19
03-27-2008, 10:12 AM
Well I comment the following:


Event.observe(window,'load',function(){ Lightbox.initialize(); });

and added the method init() for each pic.

It seems to work coz I cannot really test since I'm on an ADSL connection.:)