Home > Web Front-end > JS Tutorial > Use js to calculate the time it takes to load the page_javascript skills

Use js to calculate the time it takes to load the page_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:30:28
Original
1499 people have browsed it
Client code writing method:
Add the initial time in the Head section of the page
Copy the code The code is as follows:



Add
to Body Copy code The code is as follows:



Insert a tag with the ID TimeShow where it needs to be displayed

Server code writing:
Copy code Code As follows:

protected DateTime dt;
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnPreInit(EventArgs e)
{
dt = DateTime.Now;
base.OnPreInit(e);
}
protected override void OnLoadComplete(EventArgs e)
{
base.OnLoadComplete(e);
TimeSpan ts = DateTime.Now - dt;
Response.Write("Time to load page:" ts.TotalMilliseconds);
}
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template