HTML5 Learning--performance tools to get load time

Source: Internet
Author: User

The previous time because the project needs to get the page load time, went to see the next HTML5 in the Performane.

You can use it to get the page's detailed load time.

More about performance can be seen in http://www.cnblogs.com/CraryPrimitiveMan/p/3795086.html

After that, a gadget was written with Performane to get the page's detailed load time.

The address on GitHub is: Https://github.com/CraryPrimitiveMan/performance-tool

The test was passed only in Chrome.

Introduce times.js into the HTML you want, open the console (press F12), and refresh the page to see a detailed load time. You can also use the Times () method call in JS.

The results of the operation are as follows

Source code and comments are as follows

varTimes =function() {    varTiming =performance.timing; varLoadtime = Timing.loadeventend-timing.navigationstart;//when acquired prematurely, Loadeventend can sometimes be 0    if(loadtime <= 0) {    //The Times method continues after 200ms delay until successfulSetTimeout (function() {times (); }, 200); return; }    varReadystart = Timing.fetchstart-Timing.navigationstart; varRedirecttime = Timing.redirectend-Timing.redirectstart; varAppcachetime = Timing.domainlookupstart-Timing.fetchstart; varUnloadeventtime = Timing.unloadeventend-Timing.unloadeventstart; varLookupdomaintime = Timing.domainlookupend-Timing.domainlookupstart; varConnecttime = Timing.connectend-Timing.connectstart; varRequestTime = Timing.responseend-Timing.requeststart; varInitdomtreetime = timing.dominteractive-Timing.responseend; varDomreadytime = timing.domcomplete-timing.dominteractive;//when acquired prematurely, Domcomplete can sometimes be 0    varLoadeventtime = Timing.loadeventend-Timing.loadeventstart; //preparing objects for the Console.table method, including time-consuming descriptions and elapsed times    varAlltimes = [        { "description": "Time spent preparing new pages", "Time (ms)": Readystart}, {"description": "Redirect redirect Time", "Times (ms)": Redirecttime}, {"description": "Appcache Time", "Times (ms)": Appcachetime}, {"description": "Unload before document Time", "Time (ms)": Unloadeventtime}, {"description": "DNS Query time Consuming", "Times (ms)": Lookupdomaintime}, {Description: "TCP connection Time consuming", "Time (ms)": Connecttime}, {Description: "Request time-consuming", "duration (ms)": RequestTime}, {"description": "Request completed to DOM load", "Time (ms)": Initdomtreetime}, {Description: "Interpreting DOM tree time consuming", "Time (ms)": Domreadytime}, {Description: "Load event time consuming", "Time (ms)": Loadeventtime}, {"description": "Total elapsed from start to load", "Time (ms)": Loadtime}]; Console.table (alltimes);} Window.onload= times;//when onload, triggers the Times method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.