Joining my HTML output into a single line (Google does it)

Can nginx help me join my HTML output into a single line?

(Google does it)

I don’t wanna worry about tons of blank lines and messed up indentation.

See http://pastie.org/294626 to know what I mean.

Ok that’s it, thanks guys!

You’ll have problems with

 tags if you do that.

Redd V. wrote:

Phillip B Oldham
The Activity People
[email protected] mailto:[email protected]


Policies

This e-mail and its attachments are intended for the above named
recipient(s) only and may be confidential. If they have come to you in
error, please reply to this e-mail and highlight the error. No action
should be taken regarding content, nor must you copy or show them to
anyone.

This e-mail has been created in the knowledge that Internet e-mail is
not a 100% secure communications medium, and we have taken steps to
ensure that this e-mail and attachments are free from any virus. We must
advise that in keeping with good computing practice the recipient should
ensure they are completely virus free, and that you understand and
observe the lack of security when e-mailing us.

http://wiki.codemongers.com/NginxHttpStripModule

On Fri, Oct 17, 2008 at 4:08 PM, Phillip B Oldham
[email protected] wrote:

You’ll have problems with

 tags if you do that.

How so?

On Fri, Oct 17, 2008 at 4:38 PM, Almir K. [email protected]
wrote:

http://wiki.codemongers.com/NginxHttpStripModule

Sweet, thanks a lot mate. I hope you guys never abandon this feature.

On Sat, Oct 18, 2008 at 7:55 AM, Redd V. [email protected]
wrote:

On Fri, Oct 17, 2008 at 4:08 PM, Phillip B Oldham
[email protected] wrote:

You’ll have problems with

 tags if you do that.

How so?

Because the purpose of

 tags is generally to keep the whitespace
intact.

http://www.w3.org/TR/html401/struct/text.html#h-9.3.4

Brett

On Sat, Oct 18, 2008 at 8:57 AM, Redd V. [email protected]
wrote:

Yeah but, I never meant for it to touch what’s inside tags, only
what’s outside tags.

But you did say,

On Fri, Oct 17, 2008 at 8:57 AM, Redd V. [email protected]
wrote:

I don’t wanna worry about tons of blank lines and messed up indentation.

Almost all of your blank lines and indentation are inside of ,
or , or

, or … tags. So if you want to ignore the inside
of tags then you’d only be stripping whitespace off before and after
the tags.

Brett

On Sat, Oct 18, 2008 at 3:43 PM, Brett H. [email protected]
wrote:

Brett

Yeah but, I never meant for it to touch what’s inside tags, only
what’s outside tags.

mod_strip leaves intact comments as well as

 tags.

What about elements which are styled to have white-space intact using
CSS? For instance:

This is a
div with whitespace
intact

Will mod_strip leave that alone? I’m guessing it won’t. There’s also
to take into consideration, and linked stylesheets
defining “pre” elements. Oh, and Javascript adding it on afterwards.

Not bashing here - I think mod_strip is a great idea and I’ve used it
myself on occasion. I’ve also found that it causes some headaches with
out designers as they expect copy to lay out correct when they throw a
“pre” on there and it doesn’t.

Davy C. wrote:

But you did say,

Brett

Phillip B Oldham
The Activity People
[email protected] mailto:[email protected]


Policies

This e-mail and its attachments are intended for the above named
recipient(s) only and may be confidential. If they have come to you in
error, please reply to this e-mail and highlight the error. No action
should be taken regarding content, nor must you copy or show them to
anyone.

This e-mail has been created in the knowledge that Internet e-mail is
not a 100% secure communications medium, and we have taken steps to
ensure that this e-mail and attachments are free from any virus. We must
advise that in keeping with good computing practice the recipient should
ensure they are completely virus free, and that you understand and
observe the lack of security when e-mailing us.

On Wed, Oct 22, 2008 at 3:35 PM, jeff emminger [email protected]
wrote:

On Fri, Oct 17, 2008 at 9:57 AM, Redd V. [email protected]
wrote:

Can nginx help me join my HTML output into a single line?

Why bother? What’s it going to save… 100 bytes? Gzip seems better
if you’re just trying to compress.

For the same reason architects build their buildings according to set
sizes.

For the same reason I don’t

   type








                           like

this

                           like

this

True, but you also don’t read HTML. Machines do.

On Fri, Oct 17, 2008 at 9:57 AM, Redd V. [email protected]
wrote:

Can nginx help me join my HTML output into a single line?

Why bother? What’s it going to save… 100 bytes? Gzip seems better
if you’re just trying to compress.

(Google does it)

And Google likely just wrote their own, since they have a very
specialized end result that’s never going to have to worry about
preserving significant whitespace.

On Wed, 2008-10-22 at 18:36 +0200, Redd V. wrote:

    if you're just trying to compress.






                           like

this

That makes no sense. If anything this is an argument against having
your HTML all on one long line. If you are looking for human-readable
HTML formatting you should consider tidylib or just make sure you are
generating formatted output to start with.

For the record, I consider lossless compression (e.g. gzip) much more
reliable than whitespace collapsing if you are looking to conserve
bandwidth. It’s more effective, plus it’s nearly impossible to debug
layout issues if your output gets mangled before you see it.

Cliff

On Wed, Oct 22, 2008 at 9:38 PM, Cliff W. [email protected] wrote:

Cliff

Yeah you’re right, I could use Tidy but it’s damn slow. If I join
everything
into a single line, there won’t be any HTML formatting anymore and I’ll
have
no more worries :slight_smile: