Frodik
Frodik

Reputation: 15465

Is it good idea to compress white spaces in HTML, will this have some performance benefit?

I have a question if automated optimizing of HTML has any performance benefit ? I am using deflate on my Apache. My HTML is manually structured so it has a lot of whitespaces, so I thought if it would help to strip these whitespaces so the resulting HTML would be smaller.

Upvotes: 1

Views: 722

Answers (2)

Marcin
Marcin

Reputation: 49856

Absolutely not. gzipping in the web server will take advantage of redundancies like spaces. Any processing performed to compress spaces in your html will simply duplicate that processing, and risk messing with any CDATA you have.

Upvotes: 1

Guido
Guido

Reputation: 47665

I think that is a CPU/memory vs bandwidth usage tradeoff. You can save some bytes and use more CPU/memory. I think it depends on your application, but in many cases, using gzip to compress HTML contents is a better idea. Most browsers out there already support it.

Upvotes: 2

Related Questions