How the Web Works

What a page is made of

Work out how many separate files a browser has to fetch to show a page, and what changes when some of them are already stored.

A page looks like one thing on screen and almost never is one. What the browser fetches first is the HTML: the words, the headings, the arrangement — and, for everything that is not writing, a name saying where to find it. Each of those names is a separate file sitting on the same machine, and the browser has to go back and ask for every one of them on its own. A page with a stylesheet and six pictures is eight files and eight separate asks, not one, which is why a page can appear with its writing in place a moment before its pictures fill in.

The HTML has to come first, because it is the list

Nothing the browser knows before the HTML arrives tells it what else the page needs — the address it was given names one file and no others. So the order is fixed by what is known rather than by anybody's choice: fetch the HTML, read the names out of it, then ask for those. It also means one missing file is a small failure and not a large one. Every file is asked for separately and answered for separately, so a picture that is not there leaves a gap where it should have been while the rest of the page carries on being a page.

Worked example

A page needs five files, and each ask takes 40 milliseconds to answer. Roughly how long before the page is complete, if the browser asks for them one after another?

  1. Five files means five separate asks, because each file is answered for on its own.

    The count of files is the count of asks. That is the whole reason the number of files is worth knowing at all.

Try it together

Now count for one particular page. Its HTML names two stylesheets, four pictures and one script, and needs nothing else.

Count the HTML in as one of the files, since it has to be fetched like anything else.

    1.How many files altogether must the browser fetch on a first visit?

    Have a go

    Have a go on your own. A browser fetched twelve files for a page. The HTML was one of them and three were stylesheets, and everything else was a picture. How many pictures does the page have?

    Ready to practice?

    Eight questions on what you have just read. Nothing is timed, and you can play as many times as you like.

    Print a worksheet