Forum Moderators: phranque
It's number one in Google for a very popular term and I don't want to jeopardize it.
The users of this page are likely to be more computer savvy than average, so I would think very few users are on dial-up. BTW, is anyone on dial-up any more?
most common steps i take are obviously image optimization "save for web" in photoshop i use about 65-75% JPG and 128 colors for GIF.
call javascripts from external files, eliminate additional code from the page.
combine your CSS files if you are calling more than one one the page.
just some of my tips in case you need em, but you sound like you got a grasp on it.
[edited by: engine at 8:21 am (utc) on Sep. 17, 2008]
[edit reason] no urls [/edit]
For graphic images, first pursue the .gif or .png option. Many graphics can survive a severe color reduction - using tonyoriega's example, most nav buttons don't lose any info when set for 8 or 16 colors. This can reduce the file size by as much as 90%. You have to be careful with reducing a .jpg that much.
I generally convert to indexed color and start with 8 colors. If that kills the image, I try 16. Then 32. Then 64 . . . if you have to use 128 or 256 colors on a .gif..png, it's time to compare: save a version at that color depth, then save one as .jpg with various quality settings. See which file is smaller and choose the winner.
i have found thats not always true.... sometimes i can get a .jpg smaller in file size than a .gif with better quality, and vice versa...
so as rocknbil said, do some testing and save some space...
maybe use some CSS divs or classes to place some images?
although im not sure if that will make a difference in page size?
something like this...
<?php function html_strip_whitespace($htmlpage) { $replace = array( "#/\*.*?\*/#s" => "", "#\s\s+#" => " ", "> <" => "><", "\r\n" => "", "\r" => "", "\n" => "", "\t" => "", ); $search = array_keys($replace); $htmlpage = str_replace($search, $replace, $htmlpage); return trim($htmlpage); } ob_start('html_strip_whitespace'); ?> // all the code for your page goes here
<?php ob_end_flush(); ?>
As far as the images I take a different approach. You need to select according to the content. If for example you had a web page with really large chunks of the same color and took a screenshot of it hands down the .gif will be significantly smaller even at 256 colors. the other benefit is the text is perfectly preserved. A lot of people have the impression they are only good for small images like icons but that is not the only place they are useful.
I don't even mess with .gif where photo type images are concerned.
Use .jpg for photos. Use a noise filter and possibly a minimal blurr filter (e.g. a Gaussian blurr with 1/2 pixel radius).
For small images, only experimentation will determine the best format (.gif isn't often the smallest but it can happen).
I have one page that's over 150k and I'm wondering how important it is that I do something to make it smaller.If that's all text, I'd look hard at reducing it, but if it is mostly linked images, then size doesn't doesn't matter (to Google anyway).
Kaled.
When calculating page size, some people include the size of images. Since you did not specify, contributors to this discussion had to make a guess. Since few pages consist of 150 KB of text (i.e. the html file is itself 150KB) it was a reasonable guess.
Kaled.
So, are you saying that linked images are not counted in the page file size?
And, what other way is there of displaying images in a browser?
Total load time of a page will depend upon text and images - a page that is too slow loading may loose visitors even before it has finished. However, if the majority of your visitors use broadband, even 150KB is probably ok.
If the images are small, it is possible to embed them but this is not supported by Internet Explorer and even if it was supported, there are few circumstances in which it would be advantageous.
One area you could look at is the markup. If it is an old page with lots of <font> tags, etc., the chances are that it could be reduced in size significantly by using CSS (but it could be a big job).
Kaled.