views:

27

answers:

1

Well this probably isn't specific to rails, but in my rails app, I have a page for a show action that contains a bunch of images (4-5 images 40-60kb each).

I don't need to show them all at the same time. I am wondering what's the best way to load them so that the page loads fast and the user experience is not sacrificed either.

Should I?

1 - Just load the 1st image and then load the rest in the background with an ajax call, once the dom is ready?

2 - Should I load them on demand when the use click a link?

3 - Should I use something like a lightbox or colorbox and again do an ajax load?

4 - I also like this plugin http://www.simplesli.de/, though not sure when it means it says it "waits" for all teh images to load, if that means the page load will take forever.

Sorry about all teh questions, I am sure there is a stock answer for this. Thanks for your help!

+1  A: 

First , I would advise you to load your images from a different domain . Something like asset.yourwebsite.com . That would allow parallel requests to flow through .
Second , I think option 1 is the best . Load your dom , and then let your images load in the background . The problem with option 2 is that the user needs to wait when they click on a link which can be avoided .
Also , use HTTP caching if these images are static . That would greatly enhance performance as well .

You might want to checkout this and this .

NM
Thanks! Very helpful links also. Can you point me to any resource about http caching, specifically with rails?
badnaam
Here's one that deals with HTTP caching :http://www.engineyard.com/blog/2009/http-caching/ . This one is a good start point for general rails caching : http://guides.rubyonrails.org/caching_with_rails.html
NM
If those were helpful , you might want to accept the answer . You acceptance rate seems to be very low .
NM