You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Jaysingh Samuel <ja...@hotmail.com> on 2009/11/03 11:42:57 UTC

Minification of js files.

Hi, 
We are fetching lots of javascript source files through apache server, we use the mod_deflate there by gzip and sent across browser. So is there any apache modules which i could use to further reduce the content size of the javascript file. If i could sweep out the empty lines in the source file will be great. 
Please through some light on this. 
Thanks in advance,Jaysingh 		 	   		  
_________________________________________________________________
Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop

RE: Minification of js files.

Posted by Jaysingh Samuel <ja...@hotmail.com>.
Jerome,

Thanks a lot for your valuable input. 

thanks, 
Jaysingh 



> Date: Wed, 4 Nov 2009 08:05:25 +0100
> Subject: Re: Minification of js files.
> From: jerome.renard@gmail.com
> To: modules-dev@httpd.apache.org
> 
> Hello :)
> 
> On Wed, Nov 4, 2009 at 5:42 AM, Jaysingh Samuel
> <ja...@hotmail.com> wrote:
> >
> > Hi,
> > Instead of minifying each of the javascript file separately and then using, is there a way of embedding the jsmin/(stripping of the blank lines) in the filter module of the apache so that the js file will be minified on the fly.
> 
> Since there is a jsmin.c available here :
> http://www.crockford.com/javascript/jsmin.c I think you could bundle
> it in your module and use the JSMin API.
> However it might not make much sense to minify a javascript for every
> request. Do your Javascript files change that often ?
> I think you have to choose between the two following solutions :
> 
> 1. To pre minify javascript files by running a shell/ant/Make script
> calling jsmin and push them in your HTTP directory
> 2. To minify Javascript files by embedding jsmin.c in a custom output
> filter module so it is done on the fly
> 
> Pro and cons of option 1 are :
> Pro : easy to do, easy to maintain
> Cons : you have to run it after each update of you JS file(s), i.e it
> is not done on the fly
> 
> Pro and cons of option 2 are :
> Pro : "minification" is done on the fly
> Cons : longer to create (you have to write C code), harder to
> maintain, will use much more server resources than option 1
> 
> It is up to you to make your decision based on your context.
> 
> Hope that helps
> 
> :)
 		 	   		  
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop

Re: Minification of js files.

Posted by Jerome Renard <je...@gmail.com>.
Hello :)

On Wed, Nov 4, 2009 at 5:42 AM, Jaysingh Samuel
<ja...@hotmail.com> wrote:
>
> Hi,
> Instead of minifying each of the javascript file separately and then using, is there a way of embedding the jsmin/(stripping of the blank lines) in the filter module of the apache so that the js file will be minified on the fly.

Since there is a jsmin.c available here :
http://www.crockford.com/javascript/jsmin.c I think you could bundle
it in your module and use the JSMin API.
However it might not make much sense to minify a javascript for every
request. Do your Javascript files change that often ?
I think you have to choose between the two following solutions :

1. To pre minify javascript files by running a shell/ant/Make script
calling jsmin and push them in your HTTP directory
2. To minify Javascript files by embedding jsmin.c in a custom output
filter module so it is done on the fly

Pro and cons of option 1 are :
Pro : easy to do, easy to maintain
Cons : you have to run it after each update of you JS file(s), i.e it
is not done on the fly

Pro and cons of option 2 are :
Pro : "minification" is done on the fly
Cons : longer to create (you have to write C code), harder to
maintain, will use much more server resources than option 1

It is up to you to make your decision based on your context.

Hope that helps

:)

RE: Minification of js files.

Posted by Jaysingh Samuel <ja...@hotmail.com>.
Hi, 
Instead of minifying each of the javascript file separately and then using, is there a way of embedding the jsmin/(stripping of the blank lines) in the filter module of the apache so that the js file will be minified on the fly.
Please guide me.
Thanks in advance,Jaysingh
> Date: Tue, 3 Nov 2009 12:40:32 +0100
> Subject: Re: Minification of js files.
> From: jerome.renard@gmail.com
> To: modules-dev@httpd.apache.org
> 
> Jaysingh,
> 
> On Tue, Nov 3, 2009 at 12:15 PM, Jaysingh Samuel
> <ja...@hotmail.com> wrote:
> >
> > Hi,
> > Thanks for your input.
> > Yes we could use this, but could you tell me how this can be used in the apache for minifying the javascript. Should we have to include in any module like filter module.
> > Please guide me on this.
> 
> We you try to achieve is not quite clear to me (sorry, tired today).
> But what I would do is the following :
> 
> For each JavaScript file in your application you can run either jsmin
> (or yuicompressor : http://developer.yahoo.com/yui/compressor/)
> in order to reduce them to the bare minimum. And then you can
> configure mod_deflate to compress those files on the fly if you want.
> 
> Did that help you ?
> 
> :)
 		 	   		  
_________________________________________________________________
Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop

Re: Minification of js files.

Posted by Jerome Renard <je...@gmail.com>.
Jaysingh,

On Tue, Nov 3, 2009 at 12:15 PM, Jaysingh Samuel
<ja...@hotmail.com> wrote:
>
> Hi,
> Thanks for your input.
> Yes we could use this, but could you tell me how this can be used in the apache for minifying the javascript. Should we have to include in any module like filter module.
> Please guide me on this.

We you try to achieve is not quite clear to me (sorry, tired today).
But what I would do is the following :

For each JavaScript file in your application you can run either jsmin
(or yuicompressor : http://developer.yahoo.com/yui/compressor/)
in order to reduce them to the bare minimum. And then you can
configure mod_deflate to compress those files on the fly if you want.

Did that help you ?

:)

RE: Minification of js files.

Posted by Jaysingh Samuel <ja...@hotmail.com>.
Hi,
Thanks for your input.
Yes we could use this, but could you tell me how this can be used in the apache for minifying the javascript. Should we have to include in any module like filter module. 
Please guide me on this. 
Thanks, Jaysingh
> Date: Tue, 3 Nov 2009 11:48:13 +0100
> Subject: Re: Minification of js files.
> From: jerome.renard@gmail.com
> To: modules-dev@httpd.apache.org
> 
> Hi Jaysingh
> 
> On Tue, Nov 3, 2009 at 11:42 AM, Jaysingh Samuel
> <ja...@hotmail.com> wrote:
> >
> > Hi,
> > We are fetching lots of javascript source files through apache server, we use the mod_deflate there by gzip and sent across browser. So is there any apache modules which i could use to further reduce the content size of the javascript file. If i could sweep out the empty lines in the source file will be great.
> > Please through some light on this.
> 
> Will JSMin help you to solve your problem ?
> 
> http://www.crockford.com/javascript/jsmin.html
> 
> Have a nice day :)
 		 	   		  
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop

Re: Minification of js files.

Posted by Jerome Renard <je...@gmail.com>.
Hi Jaysingh

On Tue, Nov 3, 2009 at 11:42 AM, Jaysingh Samuel
<ja...@hotmail.com> wrote:
>
> Hi,
> We are fetching lots of javascript source files through apache server, we use the mod_deflate there by gzip and sent across browser. So is there any apache modules which i could use to further reduce the content size of the javascript file. If i could sweep out the empty lines in the source file will be great.
> Please through some light on this.

Will JSMin help you to solve your problem ?

http://www.crockford.com/javascript/jsmin.html

Have a nice day :)