471,603 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

Preload Images


Is there a way to preload a few images of a page using only CSS?
If yes, how can I do it, and should I use CSS or Javascript to do

Nov 26 '07 #1
1 2290
On 26 Nov, 11:16, shapper <mdmo...@gmail.comwrote:
Is there a way to preload a few images of a page using only CSS?
(short answer)
Yes. It just does this, it does it automatically, stop worrying about
it, everything is already working in the best of all possible worlds.
No further action is required of you.
(longer answer)
It's hard to say what "preload" means. It's not part of a web page
itself, it's something you've invented on top of this. What you've
invented might be different to what I've invented, so I can't say for
certain how yours will work.

In the past, JS was often used for menu roll-overs and the like. These
needed their "hover" images to be pre-loaded with the initial page
load, otherwise the first rollover action was obviously slow.
"Preloading" was a necessary technique.

Nowadays we use CSS for menu rollovers, not JS. If any preloading is
needed, this will have been taken care of automatically for us, by
competent browser implementations. No more effort is required, other
than competent CSS page design and coding.

This is because browsers (typical ones) understand CSS and can
recognise a likely need to preload an image (any resource named in the
CSS is likely to find itself getting loaded early - just watch the
traffic). JS is too complex, too difficult to recognise such a need,
and so the browsers don't try to automate or second-guess this.
OTOH, if you're still building some complex image gallery system with
JS, then there might be a need for preloading of thumbnails etc. This
would depend on what you're building and how you're building it. We
can't know this. CSS is unlikely to be involved it's more likely to be
JS, so you're still likely to have to build your own preloaders as
Nov 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by MALdito | last post: by
3 posts views Thread by Bob | last post: by
2 posts views Thread by jmhill | last post: by
2 posts views Thread by Albert Spencil | last post: by
1 post views Thread by Stacey | last post: by
9 posts views Thread by shapper | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.