An obvious way to improve website speed is to reduce the size of the html file. There are some methods, such as: hard compression, acupuncture-like id and changing the class name. Here are some of the ways we summarized to make html tags more streamlined.
html 4html (non xhtml), mime type is text/html, allowing some tags to be omitted. With html 4 dtd, you can omit the following tags (those so-called avoidable elements are marked with strikethrough here)
</area> </base> <body> </body> </br> </col> </colgroup> </dd> </dt> <head> </head> </hr> <html> </html> </img> </input> </li> </link> </meta> </option> </p> </param> <tbody> </tbody> </td> </tfoot> </th> </thead> </tr>For example, your code is
<li>list item</li>Can be written as
<li>list itemFor example, the paragraph should
</p>At the end, you can just write
<p>my paragraphYou can even remove html, head, body (make sure this will make you comfortable before taking this as your coding specification).
After the tag is omitted, the html is still valid, and the file size is reduced. For general pages, you can save 5-20%.
html 5The developing html 5 provides some ways to reduce file size.
For example, page document type declaration
<!doctype html>contrast
<!doctype html public -//w3c//dtd xhtml 1.0 strict//enhttp://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd>Obviously html 5 dtd is shorter.
html 5 is easy to use and shorter when specifying an encoding for a page:
<meta charset=utf-8>replace
<meta http-equiv=content-type content=text/html; charset=utf-8>Normally, the browser will handle html correctly.
In addition, in today's html 5, you can remove the type attribute that declares mime type, such as
type=text/css or type=text/javascriptYou can use
<script> Alternative <script type=text/javascript> use <style> Alternative <style type=text/css>In all types of pages (even xhtml) you can omit
type=text/csshtml 5 makes this all easier.
Using all the above methods simultaneously will save 10%-20% (or even more) of the file, depending on your encoding style and the amount of text content in the page. The code will be cleaner and visitors will get website content faster. We use a lot of this technology in the Privacy Center project, saving 20% of the original file size.