JavaScript performance optimization: loading and execution

Source: Internet
Author: User
With the continuous promotion of web technology, more and more applications are processing javascript on the client, making the performance of JavaScript in the browser the most important availability problem faced by developers. This problem is complicated due to the blocking feature of JavaScript. That is to say, when the Browser executes JavaScript code, it cannot do anything at the same time. With the continuous promotion of web technology, more and more applications are processing javascript on the client, making the performance of JavaScript in the browser the most important availability problem faced by developers. This problem is complicated due to the blocking feature of JavaScript. That is to say, when the Browser executes JavaScript code, it cannot do anything at the same time.

This article details how to correctly load and execute JavaScript code to improve its performance in the browser.

01-

Overview

Whether JavaScript code is embedded or in an external link file, the page download and rendering must be stopped and the script execution is complete. The longer the JavaScript Execution process takes, the longer the browser will wait to respond to user input. The reason for blocking when the browser downloads and executes the script is that the script may change the page or JavaScript namespace, which may affect the content of the subsequent page. A typical example is to use document. write () on a page (). Example: Listing 1

Listing 1 JavaScript code embedding example

    Source Example    

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.