Jump to content
  • 0

how to really preload an image before content?


DolbyRoom
 Share

Question

in fact how to achieve this sequence:

1) user requests index.html, style css

2) preloading image.jpg

3) loading and displaying content in <body></body>

these things didn't work for me:

<script LANGUAGE="JavaScript">

Image1= new Image(498,527)

Image1.src = "body_bg-contacts.jpg"

</SCRIPT>

and

#preload img

{

height: 0; width: 0; border-width: 0;

position: absolute;

bottom: 0;

left: 0;

z-index: -30;

}

<div id="preload"><img style="visibility:hidden;position:absolute;top:-1000px;left:-1000px;" src="images/body_bg-res.jpg" /></div>

When I used the above or similar I still had smaller images and buttons loading before my main body_bg-contacts.jpg was actually loaded.

Any ideas of how to really control image preload?

I've tried some css and javascript codes, but as I said the MAIN IMAGE is not being loaded first.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I don't think it is really possible, because it is supposed that loading markup and text before any other additional information like style or javascript or images is better practise, so browsers try to do so. Or, perhaps, some files are loading parallel with .html content, but not before. You can't pause loading a file which is already loading.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy