Home > Web Front-end > HTML Tutorial > Optimize html code to speed up web page loading

Optimize html code to speed up web page loading

巴扎黑
Release: 2017-08-21 11:29:12
Original
2506 people have browsed it
Do web developers have to master complex component technologies to speed up access to HTML pages? The answer is: not necessarily! In fact, there are many techniques for HTML and DHTML that are simple and easy to use. Whether you are a highly skilled veteran or a newbie to programming, understanding these is essential.

Obviously HTML, hidden "public 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 program used by multiple HTML pages into an independent .js file, and then call it in the page as follows:



In this way, the public file only needs 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: