Preloading Images

images php coding issues or problems here.

Moderators: macek, egami, gesf

User avatar
blake_ensenita
New php-forum User
New php-forum User
Posts: 8
Joined: Tue Jun 24, 2003 11:15 am
Location: Vernon, BC, Canada
Contact:

Preloading Images

Postby blake_ensenita » Fri Jun 27, 2003 3:56 pm

Does anybody know how to preload a file (image) so it is already loaded into the browser when the page is displayed? I'm using alot of background pictures in a css file and it is causing an attrotious "blink" every time it loads.

The javascript code:

var imagename = new Image();
imagename.src = "Images/image.jpg";

Does not work fast enough. Can anybody help?

liquedus
php-forum Active User
php-forum Active User
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Postby liquedus » Sat Jun 28, 2003 4:35 am

well once you have the object make sure you use it... can u post your code?? :lol:

also .jpg will take longer to load than .gif , so that might be a consideration.

User avatar
blake_ensenita
New php-forum User
New php-forum User
Posts: 8
Joined: Tue Jun 24, 2003 11:15 am
Location: Vernon, BC, Canada
Contact:

Postby blake_ensenita » Sat Jun 28, 2003 11:54 am

It's got to be a jpg

I can't release the source code (copyrighted stuff), but i can tell you that I'm trying to retrieve the files inside a style tag.

ie.

Code: Select all

<style>

.main { background-image: url(Images/image.jpg);

</style>

danhash
New php-forum User
New php-forum User
Posts: 6
Joined: Fri Aug 08, 2003 11:26 am
Contact:

Postby danhash » Fri Aug 08, 2003 11:43 am

preloading images is only useful for rolovers and if you use the same images on multiple pages. if you're using the same images on a bunch of pages, link to an external .js file. if it's just one page, preloading an image won't be any faster thatn letting it load itself (unless you preload it before and html, which would probably slow the whole page down)

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Fri Aug 08, 2003 1:26 pm

One situation in which this is useful is when you have a sequential presentation of some sort, like a slide show or a PowerPoint-like presentation. Since you know exactly which page the user is going to next, you can preload the images for that on the preceding page while that page is being viewed/presented.


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest