开发者

HTML - decrease page size [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_Go百科

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 5 years ago.

Improve this question

Is there any way to decrease or squish the size of a .html page?


If we are talking about size of the file in bytes, then gzipping it on-the-fly will have the biggest impact. After that, I'd suggest removing whitespaces and comments, and moving all inline javascript and css into separate files. Then you may consider trying to clean the HTML a bit, like removing tables in favor of divs and all that.

Then, if you are really going to push the limits, you may try to change your doctype to HTML4 Transitional and then exploit its un-strictness. You can remove <body> tag, you can stop closing <li>s and <td>s, you can drop off parentheses around tag attributes or remove whitespaces between them, and still remain valid. Also, if you replace all your <strong>s with <b>s, you can save up to 10 symbols per pair! :)

If you need a working example of that "pushing the limits" techniques, then go to http://yandex.ru and explore their sources. Yandex is the leading search engine in Russia, they really care about the size of their index page and they know a lot about optimizing the code and load speed of pages.


Assuming you are talking about the length of the page in bytes:

  • Make sure gzip is enabled on your server.
  • Remove comments.
  • Remove any Javascript and css - Javascript can be compressed in a separate file using a tool such as googles closure compiler.
  • Use ansi ascii or UTF8 encoding (as opposed to UCS2/UTF-16).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜