Css and image load times

G

Gin

How to load first an image that I'm positioning using css ?

The image is loaded after all the images on my html template.

I'm using css for simplicity, because with it I can position this image on
the top left side of my page, without complex
html table architectures.

Thank you
 
J

Jukka K. Korpela

Scripsit Gin:
How to load first an image that I'm positioning using css ?

The loading order can be affected in JavaScript, on browsers that have
scripting enabled. For example, put the following right after the <html> tag
(so that the code will be executed as early as possible):

<script type="text/javascript">
if(document.images) {
img1 = new Image();
img1.src = "foobar.gif"; }
</script>

(It's old-style JavaScript, but should work well enough.)
The image is loaded after all the images on my html template.

The loading order depends on many things, including their order of
appearance in the HTML source.
I'm using css for simplicity, because with it I can position this
image on the top left side of my page, without complex
html table architectures.

That's fine. If you use the same image, with exactly the same URL (after
relative URLs have been resolved to absolute URLs), then browsers will most
probably cache the image so that it is practice readily available after a
user has visited one of your pages. (Unless you do something to prevent
caching; but you probably don't.)
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Mon, 09 Jul 2007 13:56:08
GMT Jukka K. Korpela scribed:
Scripsit Gin:


The loading order can be affected in JavaScript, on browsers that have
scripting enabled. For example, put the following right after the
<html> tag (so that the code will be executed as early as possible):

<script type="text/javascript">
if(document.images) {
img1 = new Image();
img1.src = "foobar.gif"; }
</script>

Probably should be: var img1 = new Image();
 
G

Gin

Thank you, probably you are right, the image now is at the bottom of the
page, moving it on top can solve something

Bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top