Mathijs Delva
Mathijs Delva

Reputation: 1

Jquery - load certain image first

I have a question. I use the Cycle plugin on my website for a slideshow. There is a decent amount of images that are being loaded. I also use a technique to scale my background image according to the dimensions of the viewport so the image doesn't get scaled out of proportion.

Now, i want to make sure the background image loads FIRST (so directly at page load) BEFORE any of the other images of the slideshow start to load. Right now, my backgroundimage is gone (has yet to load and is being replaced by the true background-color in the css body tag) until the slideshow has been loaded.

Is there a way to do this?

Thank you very much!

Upvotes: 0

Views: 1102

Answers (1)

generalhenry
generalhenry

Reputation: 17319

You can use an ajax callback to delay until the background image is loaded

$.ajax({ url: "backgroundimage.png", success: function(){
        startSlideshow()
}});

Upvotes: 1

Related Questions