Code optimization is to make necessary adjustments to the HTML source code in the web page to improve the effectiveness of the page. After the page is optimized, on the one hand, it can effectively streamline the redundant code in the page, speed up the display speed of the page, and at the same time reduce the page's performance. It occupies the storage space of the search engine server, thereby improving the user experience and search engine friendliness of the page; on the other hand, it can highlight the theme of the page and improve the relevance of the page.
Main steps: streamlining code; header optimization, use of weight labels and image optimization. Among these four links, streamlining code is the most basic and fundamental.
1. Streamlining the code refers to clearing or simplifying the code in the page, so as to reduce the page size, improve the user experience and search engine optimization of the page.
Streamlining the code is divided into five small steps: 1. Cleaning up junk code; 2. HTML tag conversion; 3. CSS optimization; 4. JS optimization and table optimization.
1.1 Junk code refers to unnecessary code that will not affect the normal display of the page even if deleted. Don't underestimate these codes. They take up a lot of space, which not only affects performance but also affects the calculation time of search engines. Therefore, it is best to write the code by hand. If you use frontpage, Word, Dreamweaver, and other tools to write it, the garbage code generated will be There are a lot of them, so clean them up manually.
1.2 HTML tag conversion mainly refers to using short tags to replace long tags that achieve the same effect in web pages. For example, for two weeks, the fonts were bolded, but there were five more characters than for the two weeks. If there are many pages, a lot of redundant code will be generated.
1.3 css optimization. CSS optimization mainly involves changing the way CSS is called and avoiding using CSS to define styles for important content.
Using div+css to create pages can prevent junk code on the one hand, and reduce duplicate codes on the other. This approach is very search engine friendly.
1.4 js optimization. js is extremely unfriendly to search engines. Currently search engines cannot parse pages or content generated by JavaScript. Therefore, important content cannot be generated using js scripts;
1.5 Table optimization, traditional pages basically use tables. However, this method is very unfriendly to search engines, so it is not recommended to use table.
Practical combat: All the pages of my website gsm alarm system are handwritten, with almost no redundant code, just the conversion of tags, and I try to avoid long sticky notes.
There is also css optimization. I put all the styles on external pages and only need to add references in the header, which greatly reduces the size of the page.
Also, I used div+css to write each page.
There is also JS optimization. All important content does not use JS. JS is only used to display some special effects. However, the JS code is also written on the external page, and a reference must be added at the bottom of the page. Do not add it to the header. If it is in the header will also affect the performance of the page
All pages of my website gsm alarm system comply with the above rules. If there is anything wrong with the above, please give me some pointers. I would be very grateful. Okay, that’s it for today, let’s continue in the next section.
(Editor in charge: momo) The personal space of the author Qinglianzhiyao