Introduction
In this article, I explain how to count page load time using TypeScript.
Use the following procedure.
Step 1
Open Visual Studio 2012 and click "File" -> "New" -> "Project...". A window is opened. In this window, click "HTML Application for TypeScript" under Visual C#.
Give the name of your application as "Page_load_Time" and then click "Ok".

Step 2
After this session the project has been created; a new window is opened on the right side. This window is called the Solution Explorer. The Solution Explorer contains the ts file, js file, and CSS file and aspx page.

Program Coding
Load_Time.ts
- class Page_Load_Time
- {
- Load_Time(beforeload)
- {
- var beload = beforeload;
- var aftrload = new Date().getTime();
- // Time calculating in seconds
- var loadtime = (aftrload - beload) / 1000;
- var span = document.createElement("span");
- span.style.fontSize = "large";
- span.innerHTML = "You page load time is <font color='red'><b> " + loadtime + "</b></font> Second \n";
- document.body.appendChild(span);
- }
- }
- var beforeload = new Date().getTime();
- window.onload = () =>
- {
- var obj = new Page_Load_Time();
- obj.Load_Time(beforeload);
- };
default.htm




Nitin BhardwajPosted May 13, 2013, 8:16 AM
Thankx
Gabriel Espirito SantoPosted May 11, 2013, 5:18 PM
Very Nice