Remove blank spaces from HTML generated from Kuali JSP's

494 views
Skip to first unread message

Gao, Bin

unread,
Mar 16, 2011, 10:23:49 AM3/16/11
to kfs.techni...@kuali.org, rice....@kuali.org

Hello all,

 

Recently, we found a KFS page can be large up to 60MB in size. In the page, there are a lot of blank lines. A tool, HTML Tidy, can clear up the HTML, and reduce its size to 2MB. That means there are a large amount of useless blanks to be transferred to users and increase the page loading time.

 

This issue may be caused by JSP 2.0 and below, which leaves a lot of blank paragraphs in the generated HTML page. As I know, JSP 2.1 provides a page directive to trim the spaces (TrimWhiteSpace).

 

I just wonder whether anyone else in the community is using HTML Tidy, JSP 2.1 TrimWhiteSpace or similar technology in KFS implementation. If so, could you share your experience/observation with us?

 

Thanks,

 

Bin

Jerry Neal

unread,
Mar 16, 2011, 10:35:32 AM3/16/11
to Gao, Bin, kfs.techni...@kuali.org, rice....@kuali.org

Hi Bin,

 

  We are using Tidy for KRAD (actually jTidy). There is a filter that can be used in the application to tidy up the pages (including removing the blank lines). As you point out this significantly reduces the size of the response and makes the HTML much more readable. This will be in place for Rice 2.0, for pages that use KRAD (Inquiry, Lookup, and Maintenance initially). Here is a link to the project page:

 

http://jtidy.sourceforge.net/multiproject/jtidyservlet/filter.html

 

Jerry

Gao, Bin

unread,
Mar 16, 2011, 10:43:27 AM3/16/11
to Jerry Neal, kfs.techni...@kuali.org, rice....@kuali.org

Thanks, Jerry.

 

I tried the filter a little bit. It worked great for lookup/maintenance/inquiry, but the financial document and KFS logo cannot be displayed correctly since JTidy changed/removed some HTML code. Can we  use any configuration to instruct JTidy to remove the blank lines only?

 

Thanks,

 

Bin

Jerry Neal

unread,
Mar 16, 2011, 10:43:55 AM3/16/11
to Gao, Bin, kfs.techni...@kuali.org, rice....@kuali.org

Actually one more follow up on this, there is no reason why we could not apply to filter to pages still coming from Struts as well. If that is

something the community is interested in I will talk to the Rice team.

 

Jerry

 

From: Jerry Neal [mailto:jkn...@indiana.edu]

Sent: Wednesday, March 16, 2011 10:36 AM
To: 'Gao, Bin'; kfs.techni...@kuali.org; rice....@kuali.org

Jerry Neal

unread,
Mar 16, 2011, 10:46:18 AM3/16/11
to Gao, Bin, kfs.techni...@kuali.org, rice....@kuali.org

Oh, I didn’t have that problem. Yes it has lots of configuration. Here is our current config:

 

    <filter>

        <filter-name>JTidyFilter</filter-name>

        <filter-class>org.w3c.tidy.servlet.filter.JTidyFilter</filter-class>

        <init-param>

            <param-name>config</param-name>

            <param-value>wrap: 220;tidyMark: FALSE;smartIndent: TRUE;</param-value>

        </init-param>

    </filter>

 

There are several more options as well (not documented but if you poke around in the source there is a class that defines them all, can’t remember

the name of hand).

Gao, Bin

unread,
Mar 16, 2011, 10:52:24 AM3/16/11
to Jerry Neal, kfs.techni...@kuali.org, rice....@kuali.org

It would be great to put such a topic, broadly a part of web optimization, in our plate.

 

I believe MSU would appreciate any solution/recommendation to this from the Foundation.

 

Thanks,

 

Bin

Leo Przybylski

unread,
Mar 16, 2011, 11:04:34 AM3/16/11
to Gao, Bin, kfs.techni...@kuali.org, rice....@kuali.org
You can also turn on compression for your server. You're probably going to want to do this anyway. gzip compression on you're responses will significantly reduce any increase in response size created from extra whitespace.


I'd rather not use jTidy. Adding an extra library and overhead when I'm just going to use Firebug and HTTP compression seems superfluous. IMHO.



Leo

Gao, Bin

unread,
Mar 16, 2011, 11:09:03 AM3/16/11
to Leo Przybylski, kfs.techni...@kuali.org, rice....@kuali.org

Thanks, Leo.

 

This is one of solutions. Do you have any idea whether all web/application servers have such feature?

 

Bin

Leo Przybylski

unread,
Mar 16, 2011, 11:16:57 AM3/16/11
to Gao, Bin, kfs.techni...@kuali.org, rice....@kuali.org
Bin,

Not sure about all web servers, but Jetty and Tomcat support compression. Apache HTTPD and IIS  also support HTTP compression. I imagine that since compression is part of the HTTP/1.1 specification, that any web server compliant with HTTP/1.1 will.

Leo
Reply all
Reply to author
Forward
0 new messages