Forum Moderators: open
Is there any reason why preloading with Javascript is preferable? I used to think that was the only way, now I'm thinking it's old school.
<html>
<img src=/images/logo.jpg onmouseover="this.src='test2.jpg'" onmouseout="this.src='/images/logo.jpg'"><div style="display:none">
<img src=test2.jpg>
</div>
</html>
The reason I applied the style to the DIV rather than directly to the image is that in my application I have a few images to preload.
Unless I'm missing something, this new method is great!
<edit>Oh, Maybe they do then!</edit>
Before the advent of the
Image object, some designers used to preload images by including 1x1 pixel IMG elements at the bottom of the page. I think JS is still preferable in most cases -
- There's no need for extra elements in the doc (semantics etc blah)
- It gives you a chance to "corral" your images into variables / arrays for later processing.
[edited by: Bernard_Marx at 9:24 am (utc) on Nov. 24, 2006]
display:none; - see this thread: [webmasterworld.com...]