Page load JS and performance analysis method introduction

Source: Internet
Author: User

This article mainly introduces the page load JS and performance analysis methods, the need for friends can refer to the

First, load the static page to load the reference JS file, and then find the reference file contains the OnLoad function,  For example, Main.js contains the onload function, in the main.js to find whether there is a reference to other JS files, the priority to load reference JS file, the file is referenced in the order of loading and main.js in the same order. When the load is complete, the onload function is started.    Because the order of JS execution is sequential, in order to improve the speed of the page, the general practice is in the onload only painting pages, some event binding function, Ajax methods can be deferred writing.    Second, response speed Analysis 1. Tools to analyze the major browser developer tools (favorite use of Firefox) can easily view the various JS files, HTML files, CSS files and pictures of the loading and execution time. 2. Hard code Analysis in the first step we can basically locate the bottleneck JS file, in the bottleneck JS, you can use Console.time (' Test ') and console. The Endtime (' test ') statement takes the execution time of the JS function and the code block. However, the console statement is only valid in non-IE browsers, and an error is available under IE. If you prefer to use IE, use a timestamp. In the pinch, the more convenient way is to directly pinch the entire JS file, and then use the Firefox browser, press F12 can be seen in the console in the target JS all functions and code block time consuming, you can 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.