Re: Preloading images with Js - body onload or buttom of page?
It depends on the browser and how the images are being used. Firefox had, for a long time, a big disconnect between images used as <img> elements/JS .src values and images used in CSS -- the two caches never talked to one another, so if you were using the background-image property to display the images, preloading in JS wouldn't do a thing for you. (That, by the way, was the original reason for CSS sprites -- reducing the number of HTTP requests was a nice side-effect, but the fact that the browser wouldn't download a :hover state image until it was actually needed meant that CSS rollovers using images wouldn't really work until the second time you moused over something.)
Preloads for <img> elements have worked pretty consistently -- the browser can't optimize them away unless the JS engine can see that the image variable is never going to be used, and since JS can be created dynamically, that's an almost impossible call to make.
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)