I'm working on a jquery based homepage with 5 or so hidden divs, each containing several background css images.
The issue is that the browser doesn't load css images into the DOM until the visibility of the parent layer is shown, causing images to slowly load in when the layer becomes visible.
Solutions I've already considered:
- CSS sprites (too much work to redesign for this, and wont really work when showing/hiding divs)
- This jQuery plugin that auto-loads css background images (simply doesn't work for me as reported by many others).
preloading the images via js:
$(function() { function preloadImg(image) { var img = new Image(); img.src = image; }
preloadImg('/images/home/search_bg_selected.png'); });
This solution seems to load the image into the dom twice...once when the js loads it, and then again when the div layer that loads it becomes visible...so it makes 2 http calls, thus not working
Any other solutions for this problem that I'm missing?
Thanks!