开发者

compress mark-up

More a theoretical question.

We compress/minify css & js, but has anyone ever thought or tried to compress mark-up?

Q: Benefits (Pro/Contra) of mark-up compression, possible tools and scripts.

As it's hard to have a solution for this Q, I'll take the 开发者_运维问答most detailed answer.

Thanks!


markup-compression is possible and widely used. there are a few possibilities (wich can be combined):

  • compression using deflate or gzip if the clients browser accepts this (wich all modern browsers should do)
  • minify markup to kick out all the tabs, linebreaks and multiple spaces as they aren't displayed by the browser (note: this can lead to problems when using <pre> or white-space: pre;)
  • leave out some markup (wich can be tricky and you really really shouldn't do this, but google does. taking a look at the page-source you'll see theres no closing body-tag for example. for a site like google, this makes sense, as leaving out </body> saves 7 bytes of traffic, wich is really a lot if you think of the daily page-views of google)


I don't why you're looking for funny answers or think it's hard to have a solution to this question. Markup is routinely served in a compressed form, for example by using Apache's mod_deflate module. Stack Overflow itself is serving you compressed markup.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜