Home >Web Front-end >HTML Tutorial >HTML performance optimization_html/css_WEB-ITnose
Summary:
Page optimization is the necessary adjustment to the HTML code in the web page. It can effectively streamline the redundant code in the page, speed up the display speed of the web page, and reduce the storage space occupied by the web page on the search engine server. , Improve user experience and search engine friendliness. Of course, it can also better highlight the theme of the page and improve the relevance of the page. The following is what I have summarized that you need to pay attention to when writing html code, for reference only.
1. HTML tags always exist. Reduce the browser’s judgment time
2. Move the script tag to the end of the HTML file, because JS will block the display of subsequent pages.
3. Reduce the use of iframe, because iframe will add an http request and prevent the page from loading. Even if the content is empty, loading will take time
4. ID and class, if you can understand them On the basis of , simplify the naming, use '-' as the connecting symbol in the connecting words containing keywords, do not use '_'
5. Keep the same case, which is conducive to browser caching, although Browsers are not case-sensitive, but the w3c standard is lowercase
6. Clear spaces. Although spaces help us view the code, each space is equivalent to one character. The more spaces, the larger the page size. The homepages of search engines such as Google and Baidu have removed all removable spaces, carriage returns and other characters, which can speed up the transmission of web pages. You can use DW software to batch delete the spaces between tags in html. In sublime text, ctrl a, then long press shift tab to align all left, clear the spaces at the beginning of the line
7. Reduce unnecessary nesting. Try to make it as flat as possible, because when the browser compiler encounters a tag, it starts to look for its closing tag, and its content cannot be displayed until it matches, so it will be particularly slow to open the page when there are many nested tags.
8. Reduce comments, because too many comments not only take up space, but if there are a lot of keywords in them, they will affect search engine searches
9. Use css div instead of table layout and remove formatting control Tags such as: strong, b, i, etc., use css to control
10. The code must be structured and semantic
11. Try to separate css and javascript into separate files
12. Remove useless tags and empty tags
13. Use abandoned tags as little as possible, such as b, i, etc., although higher version browsers are backward compatible
Summary:
HTML pages are displayed to users. Good code can not only bring friendliness to users, but also help search engine rankings. Simplify the code structure when making pages, and make labels semantic and standardized. .