Re: Trimming the extra spaces in the output page

2003-10-20 Thread Max Cooper
First, I understand your motivation -- HTML file size can be a big
performance problem for many apps. We did some analysis on a project that I
was on and it turned out the server was quite fast, but that HTML file
transfer time and then browser redering time were the major factors in
actual performance. I would have never guessed that, but it was clearly the
case after our analysis.

In terms of a solution for this problem, I suggest not doing this at run
time, but rather do it at build time. You want to keep spaces in the file
for maintainability during development, but it would be nice to strip them
out during the build. This would avoid adding any runtime overhead. You
should be able to do this easily at build time (using Ant). This is one good
reason to have your build copy the "web" files to a new location during the
build. If you are already doing that, it should be easy to strip the
whitespace out using an Ant filter.

Be careful what you strip out.

- Getting rid of line breaks will change the appearance of your HTML files.
A line break is considered white space. If you get rid of them, you will
likely have instances where "some whitespace" becomes "no whitespace". That
will mess up your pages. I wouldn't strip these. You could replace the line
breaks with a single space to maintain the appearance, but there seems to be
no point in doing that since your won't actually be reducing the file size.
No line breaks would make the resulting HTML files very hard to read (for
debugging, etc.). Keep the line breaks.

- Don't remove all the spaces. You want to eliminate extra whitespace, but
not all whitespace entirely (since whitespace matters in HTML). You just
want to shrink consecutive runs of whitespace down to one whitespace
character, so as to preserve the appearance of the pages. I haven't looked
at what comes Ant that might be good for doing this, but it seems like there
should be some kind of filter that should help. Here's an example:

For instance, you don't want to turn this:


   Hello  world! 


Into this (which won't look the same):

Helloworld!

Or this (which also won't look the same):

Hello world!

But rather it would be best to turn it into this (which is as small as you
can make it without requiring too much smarts in the filter):


 Hello world! 


-Max

- Original Message - 
From: "EL AKARI Mehdi" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, October 20, 2003 10:33 AM
Subject: Trimming the extra spaces in the output page


Hi,
I'm trying to optimise the size of the output pages of a struts application.
The first thing that i'm trying to do is to trim the extra spaces and
carriage returns in the output page.
Do you have any ideas of how to do this?
If you have any suggestions of how to optimise the page output they are
welcome!
Thanks
Mehdi



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Trimming the extra spaces in the output page

2003-10-20 Thread Steve Raeburn
I agree with the Filter suggestion, but I would take a step back and ask
whether you *really* need to do this.

Trimming the excess whitespace won't really make much difference to the size
of the downloaded page and adding the Filter processing could even make it
slower, not faster to load.

If you're really producing pages that are too large I would first consider
the following optimizations before worrying about trimming whitespace:

 - Reduce the number and size of images in the page
 - Convert the page layout to use CSS instead of nested tables (this alone
can reduce the page weight by as much as 50%)
 - Split the page into smaller, lighter pages.


Steve


> -Original Message-
> From: James Mitchell [mailto:[EMAIL PROTECTED]
> Sent: October 20, 2003 11:40 AM
> To: 'Struts Users Mailing List'
> Subject: RE: Trimming the extra spaces in the output page
>
>
> Someone mentioned this a few weeks back.  I don't remember the solution,
> but if it were my job to make this happen, I would most likely use a
> Filter.
>
>  http://java.sun.com/products/servlet/Filters.html
>
>
> --
> James Mitchell
> Software Engineer / Struts Evangelist
> http://www.struts-atlanta.org
> 678.910.8017
> AIM:jmitchtx
>
>
>
>
> > -Original Message-
> > From: EL AKARI Mehdi [mailto:[EMAIL PROTECTED]
> > Sent: Monday, October 20, 2003 1:34 PM
> > To: Struts Users Mailing List
> > Subject: Trimming the extra spaces in the output page
> >
> >
> > Hi,
> > I'm trying to optimise the size of the output pages of a
> > struts application.
> > The first thing that i'm trying to do is to trim the extra
> > spaces and carriage returns in the output page.
> > Do you have any ideas of how to do this?
> > If you have any suggestions of how to optimise the page
> > output they are welcome!
> > Thanks
> > Mehdi
> >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Trimming the extra spaces in the output page

2003-10-20 Thread James Mitchell
Someone mentioned this a few weeks back.  I don't remember the solution,
but if it were my job to make this happen, I would most likely use a
Filter.

 http://java.sun.com/products/servlet/Filters.html


--
James Mitchell
Software Engineer / Struts Evangelist
http://www.struts-atlanta.org
678.910.8017
AIM:jmitchtx




> -Original Message-
> From: EL AKARI Mehdi [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 20, 2003 1:34 PM
> To: Struts Users Mailing List
> Subject: Trimming the extra spaces in the output page
> 
> 
> Hi,
> I'm trying to optimise the size of the output pages of a 
> struts application.
> The first thing that i'm trying to do is to trim the extra 
> spaces and carriage returns in the output page.
> Do you have any ideas of how to do this?
> If you have any suggestions of how to optimise the page 
> output they are welcome!
> Thanks
> Mehdi
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]