6

Is there a way to pre-load images just using html/css?

5 Answers 5

5

Yes you can. There are many tutorials available on this topic - here is one of them.

Sign up to request clarification or add additional context in comments.

Comments

2

Or even easier: <link rel="prefetch" href="path to image"> (Firefox).

<link rel="prerender" href="http://example.org/index.html"> (Chrome)

2 Comments

Is it? I would have hoped other browsers picked it up already.
Note/update: prefetch is HTML 5 standard. Even though I've yet not tested which browser fully implements this feature (in 2014).
0

If you include an url in your CSS, the image will be downloaded as the .css file is loaded into the document.

1 Comment

Not true, at least not for all browsers. Most browsers load CSS url's on demand, so hover images don't download until user hovers.
0

Yes: http://perishablepress.com/press/2008/04/15/pure-css-better-image-preloading-without-javascript/

1 Comment

Thanks... that url was already linked to in the above (first) answer.
0

Yes, there is. There's a technique called CSS sprites.

It basically works by loading one big image and then only displaying certain sections of the image as needed. Obviously, this technique isn't practical for every solution but it's good for many.

A List Apart has a great tutorial on this: A List Apart: Articles: CSS Sprites: Image Slicing's Kiss of Death

2 Comments

We have recently embraced this and it is GREAT!
took a look at this also. It seems very interesting.

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.