Home > Web Front-end > JS Tutorial > body text

How to improve JavaScript loading and execution efficiency

高洛峰
Release: 2017-02-03 13:23:51
Original
1399 people have browsed it

Preface

No matter whether the current JavaScript code is embedded or in an external link file, the downloading and rendering of the page must stop and wait for the script execution to complete. The longer the JavaScript execution process takes, the longer the browser waits to respond to user input. The reason why browsers block when downloading and executing scripts is that the script may change the namespace of the page or JavaScript, which affects the content of subsequent pages.

A typical example is to use document.write() on the page.

JavaScript code inline example

<html>
<head>
 <title>Source Example</title>
</head>
<body>
 <p>
 <script type="text/javascript">
 document.write("Today is " + (new Date()).toDateString());
 </script>
 </p>
</body>
</html>
Copy after login

When the browser encounters the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!