Which elements will load first in an html page?

learner picture learner · May 23, 2011 · Viewed 23.5k times · Source

I want to know which elements (html tags, scripts, styles, images) will load first when opening a web page?

Can anybody help me? Thanks in advance.

Answer

Grant Thomas picture Grant Thomas · May 23, 2011

HTML pages are interpreted on the fly and read in their entirety from top to bottom - so, the first elements will load first, the last last.

For instance, if you place a script at the top of the body then it will be executed prior to any elements within the body loading; whereas if you place is at the end of the body, all elements within the body will load then the script will execute.

The order of loading for external sources such as scripts and images, though, might differ from browser to browser (while for the most part following the same conventions) - the idea is that connections will be open to request these resources and then things like size, speed and latency come into question - and these are most often still sequential and blocking.