Each <script> tag is initially downloaded to block page rendering, so reducing the number of <script> tags included on the page helps to improve this situation. This is not only for external link scripts, but also limited the number of embedded scripts. Whenever a browser encounters a <script> tag during parsing an HTML page, it will cause a certain delay due to the execution of the script. Therefore, minimizing the delay time will significantly improve the overall performance of the page.
Usually a large website or web application needs to rely on several javascript files. You can merge multiple files into one, so that you can reduce performance consumption by simply referring to a <script> tag. File merging can be achieved through offline packaging tools or real-time online services like YaHoo!combo handle.
The code copy is as follows:
<!-- Before optimization: -->
<html>
<head>
<title>Script Example</title>
</head>
<body>
<p>Hello world!</p>
<script type="http://yui.yahooapis.com/combo?2.7.0/build/yahoo/yahoo-min.js"></script>
<script type="http://yui.yahooapis.com/combo?2.7.0/build/event/event-min.js"></script>
</body>
</html>
<!-- After optimization: -->
<html>
<head>
<title>Script Example</title>
</head>
<body>
<p>Hello world!</p>
<script src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo/yahoo-min.js&2.7.0/build/event/event-min.js" type="text/javascript" >/script>
</body>
</html>