Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate time taken to load a page

Status
Not open for further replies.

gorgered

Programmer
Dec 13, 2005
24
US
Hi,

I would like to know the time taken to render the page on to browser using javascript? How can I do this I need some hints so that I can start off.

Thanks
Gorge
 
set a date variable when the page first loads. then, in your body's onload event, call a function to set another date variable. calculate the difference, then go from there.

here's an example:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]

<html>
<head>
<script type="text/javascript"><!--

var start = new Date();

function doit() {
    var end = new Date();
    var diff = end - start;
    alert("page took " + diff + " milliseconds to load" );
}

//--></script>
<title>Untitled</title>
</head>

<body onload="doit();">


<p>hi hi hi hi hi hi hi hi <img src="[URL unfurl="true"]http://www.tawbaware.com/maxlyons/Blend_KeyBridge_Blended.jpg"[/URL] /></p>

</body>
</html>



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
For some useful tools to do this, take a look at Jeff's "Load timing and profiling tools (IE and FF)" thread posted yesterday in the HTML forum: thread215-1280237

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top