Talking about page loading js and performance analysis methods, talking about js

Source: Internet
Author: User

Talking about page loading js and performance analysis methods, talking about js

I. Loading

First load the reference js file of the static page, and then find whether the referenced file contains the onload function, such as main. js contains the onload function, in main. in js, check for references to other js files. Load and reference js files first. The loading sequence of referenced files and main. the js sequence is consistent.
After loading, start to execute the onload function. The js execution sequence is sequential. To speed up the page, you can only draw pages in onload. Some event binding functions and ajax methods can be postponed.

2. Response Speed Analysis

1. Analyze with tools

The developer tools of various browsers (like Firefox best) can conveniently view the loading and execution time of various js files, html files, css files, and images.

2. Hard coding Analysis

In the first step, we can basically locate the bottleneck js file. In the bottleneck js, you can use the console. time ('test') and console. the Endtime ('test') statement is used to obtain the execution time of js functions and code blocks. However, the console statement is valid only in non-IE browsers, and an error is reported in IE. If you prefer IE, use the timestamp. During the capture process, the most convenient method is to directly hold the entire js file, and then use the Firefox browser. Press F12 to view the time consumption of all functions and code blocks in the target js on the console, locate the bottleneck code.

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.