Slow loading JPEGs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sheridan
Forum Newbie
Posts: 18
Joined: Sat May 31, 2008 1:50 pm

Slow loading JPEGs

Post by Sheridan »

I have created a site which has JPEG files. For some reason they load very, veerrrrrry sloooowwwwwllllly.

I am using the standard HTML img src code. Is there anything I can do to speed the process?
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Re: Slow loading JPEGs

Post by panic! »

it really depends where your bottleneck is. You haven't really been descriptive enough at all.

Where is it hosted? Are the images being processed/created by GD or just plain JPGs? How big are they?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Slow loading JPEGs

Post by josh »

User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Slow loading JPEGs

Post by califdon »

Sheridan wrote:I have created a site which has JPEG files. For some reason they load very, veerrrrrry sloooowwwwwllllly.

I am using the standard HTML img src code. Is there anything I can do to speed the process?
How many files? How big are they, on average? For an entire web page, what is the total number of kilobytes that must load? What is the speed of your Internet connection? Where is the site hosted? Those are just a few of the questions you would have to answer before any kind of a sensible answer could be given.
Sheridan
Forum Newbie
Posts: 18
Joined: Sat May 31, 2008 1:50 pm

Re: Slow loading JPEGs

Post by Sheridan »

How many files? - 10 JPEG files

How big are they, on average? - 1.15 MB - 1.35 MB

For an entire web page, what is the total number of kilobytes that must load? - 13.5 MB Max

What is the speed of your Internet connection? It's a DSL connection running at 760 Kbps, Max

Where is the site hosted? - On a home computer. XP on a Pentium II with 512 MB RAM running at 299MHz
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Slow loading JPEGs

Post by onion2k »

Sheridan wrote:For an entire web page, what is the total number of kilobytes that must load? - 13.5 MB Max
A 1.15MB image downloading on a 760kbps connection takes 12.39s .. plus a bit for the browser to work out what to get. The entire page is going to take a long time - 2.4 minutes in fact. That's far too much, especially when you realise very few people's connections actually go at maximum speed.

If you want your site to appear to load quickly you need to get the entire page (all HTML, CSS, JS, images, Flash, etc) under 200kb (approximately 1/500th the size of your current page). And even that is considered a lot. When I started out in web development a decade ago 40kb was considered huge.
daniel142005
Forum Newbie
Posts: 3
Joined: Sat Sep 20, 2008 3:32 pm

Re: Slow loading JPEGs

Post by daniel142005 »

Sheridan wrote:How many files? - 10 JPEG files

How big are they, on average? - 1.15 MB - 1.35 MB

For an entire web page, what is the total number of kilobytes that must load? - 13.5 MB Max

What is the speed of your Internet connection? It's a DSL connection running at 760 Kbps, Max

Where is the site hosted? - On a home computer. XP on a Pentium II with 512 MB RAM running at 299MHz
Is the computer's internet connection on the same as yours? and are you accessing it across the network?

If they are sharing the same connection then your upload speed is probably around 100-300kbps which would slow them down even more. This doesn't apply for you if you are trying to view them on the network but it will apply for anyone outside your network (assuming it isn't specifically for local access). Also, the computer the site is hosted on is quite slow... My phone is running at 600MHz with 256mb of ram... so its possible that some performance can be lost there as well.

Another solution, if you don't really need the whole image to be loaded, is to either have GD Library (php) scale down the images before sending them (caching the small ones to prevent the server from having to generate them every time), then allow you to click them for full size, or you make two copies yourself and link to the larger one from the small ones.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Slow loading JPEGs

Post by califdon »

Sheridan wrote:How many files? - 10 JPEG files

How big are they, on average? - 1.15 MB - 1.35 MB

For an entire web page, what is the total number of kilobytes that must load? - 13.5 MB Max

What is the speed of your Internet connection? It's a DSL connection running at 760 Kbps, Max

Where is the site hosted? - On a home computer. XP on a Pentium II with 512 MB RAM running at 299MHz
Yeah, that's just never going to be a workable site for outsiders to visit. To begin with your DSL connection is probably ADSL, with an upload speed of maybe 100 kbps. Your web server has only a half gigabyte RAM. If everything is running at top efficiency, the best you could hope to get would be a load time of something like 13,500 / (100 / 8 ) = 1080 seconds or 18 minutes. It's too bad, but images for web viewing need to be very small. Even if you hosted that page on a commercial hosting service, it would be miserably slow. You are probably wasting that resolution anyway, since a typical viewer's screen size is perhaps 1280 x 1024 at most (1,310,720 pixels) at 3 bytes per pixel (for 16 million colors), so even a fullscreen image would be only around 4 mB. In any case, those jpeg are just not suitable for a web site, especially 10 of them on a page. You need to use PhotoShop or similar software to reduce the resolution.
Sheridan
Forum Newbie
Posts: 18
Joined: Sat May 31, 2008 1:50 pm

Re: Slow loading JPEGs

Post by Sheridan »

Thanks for clearing up the tech details, everyone. I decided to use GD to produce thumbnails href linked to the full size images. The page loads beautifully now.
Post Reply