Results 1 to 6 of 6

Thread: Sprite and http request

  1. #1
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Sprite and http request

    Hello everyone,

    #menu .1 {
    background: url(SPRITE.png) 0px 0px no-repeat;
    }
    #menu .2 {
    background: url(SPRITE.png) 0px -30px no-repeat;
    }
    Just wanna confirm how many http requests for background images used multiple times on the stylesheet...
    Like if I used the same image with the same url 10 times, will I have 10 http resuests too?

    Thanks in advance!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The idea of sprites is that you will not. You will load the image exactly one time and then it will be cached. Unless there is a VERY small caching setting (less than a second) it should never load more than once.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Sprites will only make one HTTP request, hence why they're so great.
    Jeremy | jfein.net

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    One possible exception - IE. The behavior of IE as regards background images is different than other browsers. This may or may not affect the number of requests for this image. It's still going to be less, or at the very least no more than using separate images. The version of IE is probably important with later versions behaving better than earlier ones.

    I'm not sure how one would test this. I have a program that allows one to track requests as a page loads, but it's old, and because of that tends to cause eventual crashes and often only works for sites on the local drive. I would hesitate to run it just to test this out because I'm sure that overall you are better off with sprites.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

  6. #6
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •