# Time it took to load

**URL:** https://forum.kirupa.com/t/time-it-took-to-load/16987
**Category:** programming
**Created:** [March 31, 2003, 3:38am UTC](https://forum.kirupa.com/t/time-it-took-to-load/16987 "2003-03-31T03:38:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Mik3](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Mik3](https://forum.kirupa.com/u/Mik3)
#### Post date: [March 31, 2003, 3:38am UTC](https://forum.kirupa.com/t/time-it-took-to-load/16987/1 "2003-03-31T03:38:29Z")

</div>

What’s the code and what code is it to show how long the page took to load?  
like at [google.com](http://google.com)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 10:46pm UTC](https://forum.kirupa.com/t/time-it-took-to-load/16987/2 "2003-03-31T22:46:33Z")

</div>

you could do something like this:

place the following in the \< head \> section of your page:

```php
<SCRIPT LANGUAGE="javascript">
loadtime="0"
loading=true
s="s"

{refresh()}

function refresh()
{setTimeout("count()",250)}

function count()
{if (loading)
{loadtime=loadtime+++0.25;refresh()}}

function done()
{if (loadtime==1)
{s=""}
document.write("It took "+loadtime+" second"+s+" to load the page");loading=false}
</script>

```

then, modify your \< body \> tag to add the onLoad function:

```php
<body onLoad="done()">

```

hope that works!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 10:55pm UTC](https://forum.kirupa.com/t/time-it-took-to-load/16987/3 "2003-03-31T22:55:11Z")

</div>

Wow, that is a nice script Liam. Did you write that yourself?

Also… you can also define the onLoad command inside the original script instead of the body tag if you wanted to 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 11:03pm UTC](https://forum.kirupa.com/t/time-it-took-to-load/16987/4 "2003-03-31T23:03:37Z")

</div>

yeah, i wrote it… took some time but i managed to figure it out!

thanks, lost, i never thought of defining it in the original script!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 11:06pm UTC](https://forum.kirupa.com/t/time-it-took-to-load/16987/5 "2003-03-31T23:06:34Z")

</div>

Well I don’t have time to test it out, but I take your word it works because I see no point in you posted code you tested, but it didn’t work 😛

:A+: I might find this useful in the future now that I think about it. I appreciate the time you spent to write this 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 11:10pm UTC](https://forum.kirupa.com/t/time-it-took-to-load/16987/6 "2003-03-31T23:10:08Z")

</div>

anytime :geek:
