1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How does a web-page load?

Discussion in 'HTML & Website Design' started by ycc, Oct 17, 2010.

  1. #1
    Hello,

    Let's say that we have a normal webpage with "embedded" elements like img-tags, javascript-files, style-sheets.

    First the browser asks for the page. Then the page is delivered to the browser.

    FIRST WHEN THE HTML OF THE PAGE HAS LOADED INTO THE BROWSER, is it possible for the browser to start downloading other elements like img-tags, js and style-sheets.

    IS THIS CORRECT?

    Or is it possible that the server examines the page and starts sending images etc. to the browser at the same time that the page is sent?

    Maybe there are several possibilities, depending on whether the other elements reside on the same server or not???

    Thanks
     
    ycc, Oct 17, 2010 IP
  2. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your code is read from start to finish, so depending on how fast your internet connection is, it can vary on how fast the page appears. So if you have a lot of JS scripts at the bottom of your page, then that will be loaded last since the rest of the page has to tbe downloaded first. That's why it's usually good to place all your essential code in the header so that it loads first. The other things that can slow it down is if you are trying to access a file from another server, which can slow down the overall load time of your site.

    As for delaying the load time, you can use a script called "lazyload" which will only load up the images in your viewport, so if there is an image at the bottom of the page, you will need to scroll down and have it appear in your viewport before it loads. This can save a lot of bandwidth and cut off time from loadtime since not all the images need to be loaded before a user can start browsing through the page.

    I am not sure exactly what you are asking, but I hope this answers your questions.
     
    GWiz, Oct 17, 2010 IP
    ycc likes this.
  3. ycc

    ycc Peon

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks GWiz,

    I think you answer the question. I have not been able to ask a very clear question, I agree.

    My basic question is that if I want to browse a webpage with an image in then I must ask the server twice. The loadtime must "double". First my browser asks for the web-page and receives it. Then my browser finds out "Ooh, there is an image in this page, I had better ask the server for that image too! "

    I am not capable of improving Internet protocols ;) But it seems like double work to me. The server should be able to say "Ooh, this guy is asking for a web-page with an image in it, I had better send that immediately together with the page, so he can browse quickly."

    The reason this came up is that I am trying to improve the loadspeed of a (Linux free-software) page that starts by getting a JavaScript-file from another server. The JavaScript -file is only one document.write('....').

    As I guess this in not a good way of organizing things. First the visitor's browser must download the web-page. Then if finds out that it cannot do anything until it has contacted another server and downloaded the javascript file.

    A JavaScript- document.write, in an includefile, early on the page will delay execution? (Especially in this case where the page comes from another server.)

    Is that true?

    If it should be included, I guess php-include would be better than JavaScript include?(First download it to the same server as the page. Do that with a script regularly.) PHP-include will be made on the server and sent together with the page?
     
    Last edited: Oct 17, 2010
    ycc, Oct 17, 2010 IP
  4. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe I am too tired today, but I still don't quite understand what you are trying to achieve. Either way, my understanding of how a page is loaded is very simple. It reads your code and loads everything as it appears. It doesn't do anything different or special when it hits a different type of element.

    So if your code looks like this:
    JS file
    JS file
    CSS file
    HTML code
    Image file
    Image file
    HTML code

    basically, it will start at the top and with the JS files and load them first, and then proceed to load the rest. If you are attempting to load something from an eternal server, then your server has to download the contents from the other server, and if it fails, it will simply continue to load the rest of the elements below. Same goes for the image files, it notices the <img> tag and knows "ok i need to access an image now", and allows the image to be downloaded and stored in your system cache.

    I don't understand why you think there is a 'double' load time, since the images are loaded DURING the loading process if anything. Your code is read from top to bottom, and it loads everything as it is read.

    As for includes, it depends on what you are trying to include and what language you are using, but a php include would be recommended over javascript includes.
     
    GWiz, Oct 17, 2010 IP
  5. ycc

    ycc Peon

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for answering the question GWiz. I understand better now, I just needed to go over the basics again before trying to improve the loadtime of a site.
     
    ycc, Oct 18, 2010 IP
  6. flight05

    flight05 Active Member

    Messages:
    122
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #6
    Theres also server side languages...
     
    flight05, Oct 23, 2010 IP