How to optimize HTML to speed up web pages

高洛峰
Release: 2017-03-10 11:49:19
Original
2238 people have browsed it

Obviously HTML, secretly crossing "public script" The key to reducing web page download times is to find ways to reduce file size. When multiple pages share some component content, you can consider separating these common parts separately. For example: we can write a script program used by multiple HTML pages into an independent .js file, and then call it in the page as followsObvious HTML, secretly transfer "common script"

The key to reducing web page download time is to try to reduce the file size. When multiple pages share some component content, you can consider separating these common parts separately. For example: we can write a script used by multiple HTML pages into an independent .js file, and then call it in the page as follows:

In this way, public files only need to be downloaded once and then enter the buffer. The next time the html page containing the public file is called again, the download time will be significantly reduced.
Let the style sheet content work underground
CSS is an HTML decorator, and a beautiful Web page cannot be without it. There are many ways to reference CSS in HTML pages, and different methods lead to different efficiencies. Usually, we can extract the style control code defined between , save it to a separate .css file, and then use the tag or @import tag in the HTML page To quote:
​                                                                                                             
Please note 2 points:

1. There is no need to include the