Jorge said:
transpar3nt said:
The only reliable way that I know of doing this is using a server
side script such as PHP or ASP. It would create a time variable upon
request and another at the bottom of the script, and finds the
difference between the two. Not sure if your server supports one of
those.
Which will tell you exactly how long that script took (fractions of a
millisecond), not how long the page[1] took to load
[1] plus linked files, plus images, plus round-trip-to-the-server
time plus lost and retransmitted paket time plus who knows what else.
<
http://jorgechamorro.com/cljs/034/>
window.onload= (function () {
var now= +new Date();
return function () {
alert(((+new Date())-now)+"ms")
};
})();
If this does what I think it does it is measuring the time between a) when
the browser has received the HTML file, decoded it, done a few other things
and finally decided to hive that CDATA off to the javascript engine and b)
when the browser has finally decided that the page has been fully downloaded
and (possibly) rendered.
OK. But what about the time between when the user "presses enter" to request
the page (as per the OPs specifications) and the browser actually gets the
page, stage a) above?
For a page that has, say, no externally linked files and no images or other
things that require a round trip back to the server (ie a simple HTML file
with perhaps some inline (or in the head) CSS) your measured time will be
sub-millisecond. The user perceived "load time" will be tens, or even
hundreds of milliseconds.
From where I am to anywhere like the U S of A, the UK and other such
northern places my single round trip time to the server is *at least* 300
milliseconds.
A more realistic page with say half a dozen images and css files and such
might fare better. The browser gets the HTML and fires off a bunch of
requests for the images etc. Lets say they take two "round trips" to the
server (the browser sends multiple gets). You are still missing the initial
round trip to get the HTML so your measurements are low by that time. Low by
one third.