To reduce the number of HTTP request for a particular web page I sprite them into one. I am using one CSS file which is being used in other pages also including different images on those pages. While loading one page it will load all the images in the respective page, but what about unused images which are included in other pages. Will they also get loaded while loading of CSS? Or do i create separate stylesheet for different pages.
Sprite images will load the whole image and then only displays the parts of the image you tell it to. Therefore unused parts are still loaded but not displayed.
You could split the big sprite up into smaller sprite depending on how many are unused when you load a page. Maybe have a main sprite for the whole site and then smaller ones on pages where they are required. I did that with my portfolio. Background and main images were in one sprite. Dates for the blog were in another
You didn’t get my point friend. I mean to say that if one css file loaded by browser, does it also load the images witch are not even included in the page. I might have made it complex to understand. Let me put this way,
After testing my website using Pingdom Tool, i found that it is taking unused CSS elements into account while calculating page speed. There are some images which are not used in a particular page but still counted by Pingdom tool just because they are included in the same CSS file.
Either this tool is wrong or my assumption, have to figure out. What will be your take on it (chriscoyier, noahgelman )?
A page will NOT load an item in your CSS file that it isn’t using.
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. This image should not load (you would notice hang time on a 5mb file loading).
This is my understanding, feel free to prove me wrong!
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.