I want to show the users how long the page takes to fully load in the footer of my website.
How do I go about doing this? I assume there is a function that can be used for this?
Not sure what language this type of feature is developed in?
Any help would be appreciated, thanks.
You need two times: the starttime and the endtime. Using JavaScript the starttime can only be approximated because the script will only fire when it is loaded, not before. This means that you will not measure stuff like DNS looking, initial latency and initial downloading. If you're fine with this limitation do this:
onload
determine the current time againAnother caveat: Stuff that gets loaded via ajax is not measured here either. The
onload
fires before the ajax stuff runs.2 simple steps to show load time on your page:
1. Put this code at beginning of your page:
2. Put this code at the end of your page:
You may try like this:
As commented by Ed Heal you need to use JavaScript as network/proxy/routes need to be factored in.
Also you may try this approach as well:
From the source
Put the following code at the very top of your PHP page (if you measure the time needed for particular part of the code put this right before that PHP code part)
The following code has to be put at the very end of the web page (or the end of the PHP code part)