Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1364 How can I calulate how long it takes to render a page?

You are here: irt.org | FAQ | JavaScript | Misc | Q1364 [ previous next ]

Try:

<html>

<head>

<script language="JavaScript"><!--
var start = new Date();

function finished() {
    var finish = new Date();
    var difference = Date.parse(finish) - Date.parse(start);
    alert(Date.parse(finish) + ' ' + Date.parse(start) + ' Loaded in ' + (difference/1000) + ' seconds');
}
//--></script>

</head>

<body onLoad="finished()">

<script language="JavaScript"><!--
for (var i=0;i<10000;i++) document.write('<br>' + i);
//--></script>

</body>

</html>

If you cannot amend the page to be timed - perhaps you don;t own it, or its on another server - then you could use the following:

<html>
<head>
<script language="JavaScript"><!--
var start = new Date();

function finished() {
    var finish = new Date();
    var difference = Date.parse(finish) - Date.parse(start);
    alert(Date.parse(finish) + ' ' + Date.parse(start) + ' Loaded in ' + (difference/1000) + ' seconds');
}
//--></script>
</head>

<frameset onLoad="finished()">
  <frame src="blank:about">
  <frame src="page_to_be_timed.htm">
</frameset>
</html>

©2018 Martin Webb