CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 24th, 2009, 09:59 AM
MagSafe MagSafe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 84 MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 22 h 52 m 26 sec
Reputation Power: 71
Replacing <img> tag with <div style="background-image: ;"> for speed improvements?

Hi there,

I've read that for using decorative images in web design its preferred that you apply them as background images instead of using the <img> tag, as using the <img> tag stops the page from displaying until all the images have fully loaded in the browser, where as using a css background image will output the page completely, then start to load in the images (users can start reading the text whilst the images load in).

I was just wondering really if anyone else has used this method and gone to the extreme measure if replacing all <img> tags with css background images to dramatically improve their page load speeds?

So for example...

before
Code:
<img src="my_thumbnail.jpg" alt="Thumbnail Graphic" title="Thumbnail Graphic" width="100" height="70" />


after
Code:
.thumb {
background-repeat: no-repeat;
width: 100px;
height: 70px;
}

<div class="thumb" style="backgound-image: url('my_thumbnail.jpg");"></div>


Just an idea really, not sure on how standard compliant it is but I might test it out later to see what speed improvements it brings. I'd be very interested in anyones thoughts

Reply With Quote
  #2  
Old June 24th, 2009, 01:04 PM
SoLoGHoST SoLoGHoST is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 9 SoLoGHoST User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 10 m 10 sec
Reputation Power: 0
Hello, yes, using the CSS Rule, background or background-image to set an image is way better. Not only does it load the page faster, but if there are problems with the image, it will not display an ugly Red X in IE. That is the image will just not be displayed at all as it does in Firefox, but also will do this for IE Browsers as well. Definately a better idea to use the background: url('images/blah.png') no-repeat; or background-image: url('images/blah.png'); background-repeat: no-repeat; instead of using <img> tags whenever possible. And since you can link it to a style sheet for a class, you can then assign this class to any <div> <span> <td>, etc. element so it will load more than 1 time from the same call, which improves overall speed and easier to maintain your images. I use background or background-image whenever possible and suggest that everyone else does too.

Just my 2 cents

Reply With Quote
  #3  
Old June 24th, 2009, 02:26 PM
Skipt's Avatar
Skipt Skipt is offline
CSS Guru in Training
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2009
Location: Maryland, USA
Posts: 2,044 Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 84 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 1 h 59 m 48 sec
Reputation Power: 1225
Send a message via AIM to Skipt
Facebook
Use background images for stuff like gradients, and as you say, decorative images. Images that add content to the page should be put in <img> tags with an alt attribute. As far as I know, there shouldn't be any page load differences because you are still loading the image.. Cache may play a part also..
Comments on this post
Akh agrees!
__________________
"Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

Reply With Quote
  #4  
Old June 24th, 2009, 05:31 PM
MagSafe MagSafe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 84 MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 22 h 52 m 26 sec
Reputation Power: 71
Thanks for the replies,

I experimented with the idea there and made all of the images on my homepage as background images, however it didn't really work very well as the progress bar would indicate the page was loaded and some crucial images weren't appearing, so I'm just going to leave it as it is.

Reply With Quote
  #5  
Old June 24th, 2009, 05:42 PM
Skipt's Avatar
Skipt Skipt is offline
CSS Guru in Training
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2009
Location: Maryland, USA
Posts: 2,044 Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)Skipt User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 84 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 1 h 59 m 48 sec
Reputation Power: 1225
Send a message via AIM to Skipt
Facebook
I shouldn't really think that the page load would be faster considering you are still loading the same image.

Reply With Quote
  #6  
Old June 25th, 2009, 06:54 AM
MagSafe MagSafe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 84 MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level)MagSafe User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 22 h 52 m 26 sec
Reputation Power: 71
Quote:
Originally Posted by Skipt
I shouldn't really think that the page load would be faster considering you are still loading the same image.


You'd be surprised, loading every image as a background image appears to make the page load almost instantly ...but without images appearing straight away (this being the only drawback).

Its probably a good method to use for some things, just not what I tried it out on (http://summeraway.com ...any thoughts welcome )

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Replacing <img> tag with <div style="background-image: ;"> for speed improvements?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
Stay green...Green IT