You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Rees <dr...@gmail.com> on 2011/03/24 02:04:16 UTC

Minify tapestry.js (and other js/css)

I'm looking for an effective way to minify tapestry.js (along with
other Tapestry supplied js/css).  I've found a good way to do this for
the prototype/scriptaculous JS by overriding the the
"tapestry.scriptaculous" factory default mapping and using my own
supplied JS like tapx-prototype.

But short of re-bundling tapestry, I don't see a way to do that for
the other Tapestry js/css?  tapestry.js in particular minifies very
well because of all the comments going from 54 kB to 16.7 kB using the
yui compressor.  Even after gzip content encoding it's significantly
smaller - 5 kB vs 15 kB.  This adds up very quickly on a high traffic
site - Javascript/CSS are a significant user of bandwidth.

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Minify tapestry.js (and other js/css)

Posted by David Rees <dr...@gmail.com>.
On Wed, Mar 23, 2011 at 7:44 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Wed, 23 Mar 2011 22:04:16 -0300, David Rees <dr...@gmail.com> wrote:
>
>> I'm looking for an effective way to minify tapestry.js (along with
>> other Tapestry supplied js/css).
>
> It's in the plan to have this out-of-the-box for 5.3. With the automatic
> gzipping provided by Tapestry, the gains of using minification are lowered.

Yeah - I read that.  Unfortunately I can't quite wait that long. ;-)

>> But short of re-bundling tapestry, I don't see a way to do that for
>> the other Tapestry js/css?
>
> URL rewriting. In the 5.1 API, you could this by writing a rewrite rule that
> changes the request path. In 5.2, it was replaced by the LinkTransformer
> API, but I don't think it supports rewriting of URLs which aren't component
> or render requests. On the other hand, you can do this in 5.2 by writing a
> RequestFilter that changes the request path (by creating Request wrapper
> object which returns a different value in getPath() and passing it to the
> next filter) and contribute it before the other request filters.

Actually, I just figured out a way (thanks to my friend) - looks like
there are SymbolConstants DEFAULT_JAVASCRIPT and DEFAULT_STYLESHEET
for tapestry.js and default.css in 5.2.  Don't see one to override
tapestry.js for 5.1, though. (yeah I know I need to upgrade those
apps!)

>> tapestry.js in particular minifies very
>> well because of all the comments going from 54 kB to 16.7 kB using the
>> yui compressor.  Even after gzip content encoding it's significantly
>> smaller - 5 kB vs 15 kB.
>
> I didn't expect all this difference between minified vs non-minified gzipped
> content. Thanks for the info. ;)

Yes - minifying js/css before gzipping can still make a significant
difference in file size.

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Minify tapestry.js (and other js/css)

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 23 Mar 2011 22:04:16 -0300, David Rees <dr...@gmail.com> wrote:

> I'm looking for an effective way to minify tapestry.js (along with
> other Tapestry supplied js/css).

It's in the plan to have this out-of-the-box for 5.3. With the automatic  
gzipping provided by Tapestry, the gains of using minification are lowered.

> But short of re-bundling tapestry, I don't see a way to do that for
> the other Tapestry js/css?

URL rewriting. In the 5.1 API, you could this by writing a rewrite rule  
that changes the request path. In 5.2, it was replaced by the  
LinkTransformer API, but I don't think it supports rewriting of URLs which  
aren't component or render requests. On the other hand, you can do this in  
5.2 by writing a RequestFilter that changes the request path (by creating  
Request wrapper object which returns a different value in getPath() and  
passing it to the next filter) and contribute it before the other request  
filters.

> tapestry.js in particular minifies very
> well because of all the comments going from 54 kB to 16.7 kB using the
> yui compressor.  Even after gzip content encoding it's significantly
> smaller - 5 kB vs 15 kB.

I didn't expect all this difference between minified vs non-minified  
gzipped content. Thanks for the info. ;)

> This adds up very quickly on a high traffic
> site - Javascript/CSS are a significant user of bandwidth.

Agreed. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org