Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are the images downloaded on when you scroll?

How can I achieve the effect where the images are only downloaded once you scroll to that content. Thus if you have a big page and there are images at the bottom of the page, they never get downloaded unless you scroll to that content. If you are still not clear, please watch imdb:

http://www.imdb.com/title/tt1385826/

Let the page load and then scroll to the Cast section. You see only when you scroll the browser makes request for the images and are downloaded. Do I have to write any special code to make that happen for each and every image on my page?

like image 317
TCM Avatar asked Jul 08 '11 14:07

TCM


1 Answers

I think that you have to use javascript; when moving the viewport of the webpage, you can calculate when a picture comes into view. At that time you can swap the path of the placeholder image to the correct image.

Here's a page with some explanations: they use this jQuery plugin

like image 180
samy Avatar answered Sep 18 '22 20:09

samy