Optimizing Repeating CSS Background Images

This is a discussion on "Optimizing Repeating CSS Background Images" within the Web Page Design section. This forum, and the thread "Optimizing Repeating CSS Background Images are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 30th, 2007, 19:44
New Member
Join Date: Jul 2007
Location: Over there
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Optimizing Repeating CSS Background Images

I've searched for an answer to this question and haven't come up with anything yet. Using background repeat in CSS I am able to make a seemingly solid area with an image that is only a few pixels in width or height. For example, as a background to the content area in the new layout for Themebot, I set background: repeat-y, and the dimensions for the image are 994px by 1px.

I am assuming that cropping the background image down to 1px in height will use the least bandwidth to load since the image is as small as possible. However, I'm wondering how the image is repeated. This must be done on the visitors computer and I'm wondering if this would create any issues with users who have slow computers. Are there any advantages to having the height be 10px or larger as opposed to just 1px? Will the page seeming load faster if a larger image is being repeated?
Reply With Quote

  #2 (permalink)  
Old Dec 30th, 2007, 21:25
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Optimizing Repeating CSS Background Images

Well, the image will only be loaded by the user's computer once, and is repeated as many times as necessary. The smaller the image, the better, since it will load faster.

Hope that helps. Cheers
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #3 (permalink)  
Old Dec 30th, 2007, 22:39
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 942
Blog Entries: 2
Thanks: 5
Thanked 18 Times in 16 Posts
Send a message via Skype™ to Aso
Re: Optimizing Repeating CSS Background Images

If you are using an image to simply represent a solid colour, then use
Code: Select all
background: #ffffff; /*Replace with appropriate HEX*/
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
  #4 (permalink)  
Old Dec 30th, 2007, 22:45
Ed Ed is offline
Highly Reputable Member
Join Date: Jul 2007
Location: Cork, Ireland
Posts: 689
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Optimizing Repeating CSS Background Images

You might find this of use too.

It's got a good selection of Colour Hex Codes.

Thanks,
Ed
Last Blog Entry: Happy New Year! (Dec 31st, 2007)
Reply With Quote
  #5 (permalink)  
Old Dec 31st, 2007, 00:58
New Member
Join Date: Jul 2007
Location: Over there
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Optimizing Repeating CSS Background Images

The only time I use an image for solid color is to compensate for shoddy PNG support among different browsers. It seems that the browser has to work harder to render a background with a single pixel height as opposed to multiple pixels in height. Need to experiment a little to find the best trade-off.
Reply With Quote
  #6 (permalink)  
Old Dec 31st, 2007, 00:59
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: Optimizing Repeating CSS Background Images

I generally don't keep image dimensions less than 10 pixels if it's repeating. Especially if it's something like 1px by 1px, the browser has to repeat it millions and millions of times. For the most part, it doesn't really matter, but that added 9 pixels might speed up the website for what little extra bandwidth it will initially take.
Reply With Quote
  #7 (permalink)  
Old Dec 31st, 2007, 10:30
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 942
Blog Entries: 2
Thanks: 5
Thanked 18 Times in 16 Posts
Send a message via Skype™ to Aso
Re: Optimizing Repeating CSS Background Images

Quote:
Originally Posted by undoIT View Post
The only time I use an image for solid color is to compensate for shoddy PNG support among different browsers.
Are you referring to the inconsistent tone in browsers such as IE7, where the PNG appears slightly lighter / darker than it should?

You can fix this using TweakPNG and simply deleting the GAMA chunk of the file
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
  #8 (permalink)  
Old Dec 31st, 2007, 18:40
New Member
Join Date: Jul 2007
Location: Over there
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Optimizing Repeating CSS Background Images

I was aware of TweakPNG but never tried it. Might have to give it a go on the next project that needs the tweak. Thanks!

Back to the issue of browser generation. I resized a background image I'm using from 994x1 to 994x108. The filesize increased from around 300bytes to around 600bytes. Still very small. Since it only needs to be downloaded once and is then cached, I think this is better than having the browser redraw the entire area using a 1px height image each time somebody browses to a new page.

I'd like to see some benchmarks on this, and I'm sure there is variance between browsers. Not sure how to go about benchmarking though.
Reply With Quote
Reply

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
Is it possible to have 2 background images? lmc148 Web Page Design 8 Jun 17th, 2008 01:46
repeating background issues. Therealmatt Starting Out 4 Sep 20th, 2007 22:54
Disappearing Background Images (IE6) kidreapertronV Web Page Design 14 Jun 8th, 2007 16:45
Repeating an image along the bottom of the page without setting it as background. imagius Web Page Design 9 Apr 27th, 2007 08:35
Is it possible to have 2 repeating background images? dragonator Web Page Design 1 Dec 9th, 2005 00:09


All times are GMT. The time now is 04:43.


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