SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP Order of Loading

    Hello,

    I made a few websites such as muchgames.com.
    I was always wondering how some sites (gamespot.com for example), create their code so that it loads the text FIRST .. then the images afterwards. Another thing I noticed is that in gamespot.com for example, the left middle and right <td> loads before the inner content of the middle frame loads.

    How is this possible?
    There is soo much content in the middle <td></td>. How can the right <td></td> load before the middle one fully loaded?

    Is there a way to have the PHP parser order the components to be loaded with some sort of function?

    I hope I'm making any sense here.. I don't know how else to explain myself.

    Thank You for your time,
    Armin
    Online Games - Play Free Online Games
    Arcade Games - Tons of Arcade Games
    Watermark Tool - Protect your Photos

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php has nothing to do with this. all the browser sees is the html generated by php, which is no different from just a plain foo.html page. the browser parses the html, and loads things in the order based on that.

    im not really sure how the browser decides which objects to load first, but i would imagine it loads them roughly in the order they appear in the html. you could place them in the html in the order you want them loaded in, and use css to position them.

  3. #3
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a way to have the PHP parser order the components to be loaded with some sort of function?
    Not one I know of.

    However you could prevent the server from sending HTML before enire PHP is parsed. The function you could use here is ob_start. But I don't think this would solve your problem

  4. #4
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do not know how these websites do that, but the only way I can think of so far is using Javascript (onload event) and [optionally] AJAX.

  5. #5
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make sure you have height and width attributes for your images. AFAIK that allows the browser to lay the page out before it's downloaded the images to see their size. Not sure if setting dimensions in CSS works as well, but that is what I do for common images.

    If your using a CSS layout you may be able to re-arrange your code so the most important content appears first in the document.

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for all your answers.

    Two of you mentioned that CSS could be used to re-arrange things.
    I'm gonna look further into that. If I figure something out, i'll post it here.

    Thanks Again
    Online Games - Play Free Online Games
    Arcade Games - Tons of Arcade Games
    Watermark Tool - Protect your Photos

  7. #7
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Also what should you consider is the tableless design. It is well known that the Internet Explorer shows up the page with tables only when the table is fully loaded, including the images.
    Saul

  8. #8
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CSS positioning can have the middle layer code before or after other code yet still be in the right position. Other than that, no options. Image caching on the client side would enable images to load instantly so that is why you may think that images are loaded first. You can also have "preload image" code in JS to load the images then load the content but this is usually an undesired effect.


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
  •