Not exactly random, but it works like this -
The code on the page is parsed from <html> to </html> by the client browser.
Each external reference is requested from the server as it is encountered in
that parsing. As the requested files have been received by the browser,
they are rendered onto the page. Since files are packetized when they are
transmitted, some files will arrive and be rendered before other (perhaps
ones that have been requested earlier even) files.
If you want to optimize the arrival of a page element, its markup must be
moved higher in the code. Since location in the code often determines
location on the page, this may not be a good solution.