SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Corner seat
    Posts
    1,069
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reducing the number of HTTP requests

    In an effort to reduce the number of HTTP requests, I decided to use the following scripts to display a certain image many times over in one page:

    The following part is called in the header.
    Code:
    <script type="text/javascript">
    <!--
    var imgMyImg = "img/myImg.gif";
    //-->
    </script>
    And the following part is called 20 times or so.
    Code:
    <script type="text/javascript">
    <!--
    document.write('<img class="default" src="' + imgMyImg + '">');
    //-->
    </script>
    <noscript>[Display something]</noscript>
    My question is

    q. Does this enforce an html page to make only 1 http request to display the image 20 times?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by stoli_sambuca
    q. Does this enforce an html page to make only 1 http request to display the image 20 times?
    If you're displaying the same image over and over, only one request should be made for that image anyway. The rest of the time it reuses that same image, script or not.

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Corner seat
    Posts
    1,069
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it. Thanks. One more question.

    When an image is loaded, it doesn't show up sometime. Is there some way to make sure that it shows up or there is a better chance of showing up correctly?


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
  •