Shipow
Shipow

Reputation: 2447

Best solution for Slider to load images one by one?

I have a Slider with 7 big images and i'm looking for a javascript/ajax solution to load this images one by one. The browser should begin to download the second image only when the first is complete, etc..

What's the best practice for that need ?

For now, I got 2 approaches :

Thanks !

Upvotes: 3

Views: 2191

Answers (1)

PHearst
PHearst

Reputation: 771

Using the Image constructor and defining its src property, the image will begin downloading. Register an onload event for the image and ensure that it's downloaded before inserting the image into the DOM.

A simple preloading example

Upvotes: 1

Related Questions