0

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!

2
  • You can create a javascript image object with your background as source and have this code inside the <head> of your html. Commented Nov 5, 2010 at 18:12
  • Alternatively you could try adding the images in after the page has loaded with javascript. This will of course break for users who don't have javascript. @Mikhail's suggestion sounds reasonable. Commented Nov 5, 2010 at 18:14

1 Answer 1

1

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

$.ajax({ url: "backgroundimage.png", success: function(){
        startSlideshow()
}});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.