Preloading images, anything i should know?

This is a discussion on "Preloading images, anything i should know?" within the JavaScript Forum section. This forum, and the thread "Preloading images, anything i should know? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 20th, 2007, 15:32
Reputable Member
Join Date: Jul 2007
Location: Windsor, ON, Canada
Age: 19
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Preloading images, anything i should know?

I'm likely gonna do some javascript preloading for most images on my site (particularly the full size ones in the galleries), and i just want to know if there are any potentially major issues with doing this, and where i should have the preloading done (aside from at the end of the page).

Just being careful
Reply With Quote

  #2 (permalink)  
Old Jul 22nd, 2007, 03:36
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

Might I suggest something like Lightbox? It's an awesome little app for galleries. It uses Ajax to load the images when they're clicked on so the user doesn't have to wait an extra minute for the thumbnails page to load.

Ajax is probably the best way to go, but if you want an instant gratification loading style, keep preloaded images to a minimum. I wouldn't go over 100kb personally.
Reply With Quote
  #3 (permalink)  
Old Jul 23rd, 2007, 00:52
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

It is possible to start loading the images as soon as the users hits the home page this would mean that some (or all depending on the amount and/or size) of the images would be stored in the cache when they got to your gallery page(s)and could mean almost instant loading of the pics. This is a pretty cool trick when used properly.

Pete.
Reply With Quote
  #4 (permalink)  
Old Jul 23rd, 2007, 00:55
Reputable Member
Join Date: Jul 2007
Location: Windsor, ON, Canada
Age: 19
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

well, yeah, but what if you're loading several dozen images? including some big ones of about 200kb each?
Reply With Quote
  #5 (permalink)  
Old Jul 23rd, 2007, 01:04
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

Well I don't see a massive problem with it to be honest. If you make sure the page loads fully first and then start to load them, it shouldn't really bother the user and although they might not all load, it will at least give them a head start so the load time on you gallery pages is less.

Just a possible solution to a potential problem. The alternative is to use thumbnails (actual thumbnails, not the proper image resized) and only load the full size image when the thumb is clicked. Maybe be better than loading all of the full size images in one go.

Try both and see what load times are like. 1 200kb image is one thing but ten or twenty may be a bit much even with fast connections. I find that pages on my sites are lighter now than they have ever been and I try to keep it that way. Have you considered using a JS image gallery (as ryan suggested) like lightbox or even building your own. It would possibly remove the problem of loading all images at once.

Pete.
Reply With Quote
  #6 (permalink)  
Old Jul 23rd, 2007, 06:59
sannbe's Avatar
SuperMember

SuperMember
Join Date: Dec 2006
Location: San Francisco
Age: 57
Posts: 1,567
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

I have to agree with Pete's suggestion about using thumbnails and click for full size pictures. I am building a bookstore site where each listing has the cover of the book shown. Lost of images. All, I repeat, all are thumbnails. I changed this on my own when I realized how long it was taking to load pages using my little Apache server on my computer. And when I uploaded to test some pages....zoom...images on steriods.
Last Blog Entry: More Sara Blogging (Nov 29th, 2007)
Reply With Quote
  #7 (permalink)  
Old Jul 23rd, 2007, 08:34
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

And there are loads of apps out there that will create thumbnails of files en masse so you don't have do each one manually. They'll even leave the file name as it is and append somethin like '_thumb' to it so it easy to recognise but diffferentiate from the original.

Pete.
Reply With Quote
  #8 (permalink)  
Old Jul 23rd, 2007, 11:06
Reputable Member
Join Date: Jul 2007
Location: Windsor, ON, Canada
Age: 19
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

Already made the thumbnails myself, cause i want them all to be square, so i just do a zoomed in portion of the picture.

but how do you load *achoo!*... good god, my allergies are getting THAT bad?... where was I? oh yeah, how do you use javascript to load all the images at once? I'm sticking with my gallery design for now because it's relatively original, and the javascript only takes up 8 lines or so (just some DOM stuff), but if there's a way other than
Code: Select all
img1 = new Image();
img1.src = "http://www.host.com/username/pic.png";
I'd like to know, if it's more efficient without being too much more code.
Reply With Quote
  #9 (permalink)  
Old Jul 23rd, 2007, 12:03
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Preloading images, anything i should know?

Not sure, never really done. You'll have to do that for every single image you want to preload though which could be quite a lot of JS code. It should all be in an external file so it won't clog up your html but its still not ideal. I'm pretty sure there must be a simpler way than this for loading a lot of images. I'll have a little look and see I can find a method.

Pete.
Reply With Quote
Reply

Tags
cons, preloading images, pros

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
preloading using a swf? nikising Flash & Multimedia Forum 7 May 23rd, 2007 08:42
Preloading problems in IE gotlisch JavaScript Forum 0 Jun 2nd, 2006 09:33
preloading CSS in a webpage shahid Web Page Design 1 Oct 1st, 2005 02:19
preloading images into browser cache gwx03 Flash & Multimedia Forum 3 May 29th, 2004 16:58
Preloading Images dannc Flash & Multimedia Forum 3 Feb 22nd, 2004 19:21


All times are GMT. The time now is 10:46.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43