Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Does webpage loading also load unused images from the CSS? Re: Does webpage loading also load unused images from the CSS?

#71446
manojgoure
Member
"TheDoc" wrote:
You can easily test this by uploading a 5mb image to your server, calling it in your CSS file but NOT using that specific class on any page.

You didn’t get my point. The thing that you just explained need a small correction as per my question, you meant "NOT using that specific class on any page." I used the class in some other pages.

OK, to make you understand better I elaborate it.

There is one stylesheet

<link rel="stylesheet" href="style.css" type="text/css" />

Having two classes calling two different images.

.image1 {
background:url(image1.jpg);
}

.image2 {
background:url(image1.jpg);
}

Now i have two pages webpage1.html and webpage2.html

I am using class .image1 in webpage1.html and .image2 in page webpage2.html.

Now my question is If I open webpage1.html, while this page getting loaded all the css (style.css) also be loaded so will it also load image2.jpg as it is in the same CSS file used by some other page (webpage2.html) but not by the existing page (webpage1.html)?

My assumption was that it should not load image2.jpg. But while testing my website for page speed by using Pingdom Tool, I noticed that it is taking all images those are not even used by any particular webpage. If any webpage rendering also takes into account unnecessary loading of unused objects for a particular webpage used by some other webpage, then its better to create separate stylesheet for different type of pages.