Is HTML too much text for fast web?
Does anyone know anything about the efficiency of HTML as a transmitted markup language? It seems to me that having closing tags rather than merely a closing curly brace (or just </>
) adds a lot of text to a file. Bandwidth is a valuable resource, and when billions (trillions?) of HTML files are continually being transmitted around the world, those closing tags a开发者_开发技巧dd up.
My question is whether they add up enough to make a serious difference. With a briefer closing tag, would there be a noticeable increase in the speed of page loads?
No.
If you want smaller download sizes, configure your web-server automatically to gzip
-compress all text/html
responses.
No. Relative to images (and video!) HTML is still tiny. Throw in compression and it becomes more so (especially as repeated strings (such as tag names) compress well.
The increase in maintenance costs would more than offset the bandwidth savings.
HTML is not efficient, and every indication suggests it will become less efficient.
Take a look at the following example:
<b>some bold text</b>
vs
<span class="boldText">some bold text</span>
.boldText {font-weight:bold;}
Ok - its a small example, but it does illustrate my point.
Back in the days of 56k modems, I used to write Javascript functions client side, and then used Ajax (before it was called ajax) to pass down just the values (not the description) and then use the client side to build up elements in the DOM, this proved about 20% more efficient, but left me thinking if anyone would invent HTML shorthand. No one did, and instead we've just upgraded our connections, and you're right - we're throwing around tons of bits, that don't need to be there.
But who cares?
Your point is valid, but compared to rich media such as audio, video, and images, the "wasted space" is negligible.
HTML, being a markup language, is verbose; but if you take away some of that verbosity, it will suddenly become much more difficult to work with.
In general, HTML markup is not the limiting factor as far as bandwidth is concerned. Two main reasons:
- HTML is text, which means it is highly compressible using HTTP compression.
- The bandwidth used by HTML is extremely small compared to the bandwidth used by graphics/video.
While technically the closing tags adds a certain percentage to the file size of HTML, it is still infinitesimally small in the grand scheme of all the data flying around the web.
If you are really concerned about it, you can always set up your web-sever to apply compression to html content when it is being served.
Google omits the closing tags on its web pages, but after compression the savings is minimal. Most people prefer to conform to standards and be able to validate their pages.
http://code.google.com/speed/articles/optimizing-html.html
精彩评论