Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Misc | Q1364 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.