This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP page with js file compression

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to render the user a jsp page and in the jsp page,there is a javascript called.Now this js file is of 100kb.I want to compress this file while sending it to the user.How can i do it??? I am using Websphere server.

Thanks in advance,
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compress how? Using gzip? Using JavaScript minification?
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dont have much of an idea..about which method to follow.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As this really doesn't have anything to do with JSP, it's been moved to a more appropriate forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest approach would be to use on of the JavaScript "minimizers". These tools compress the JavaScript by removing whitespace, replacing long variable names, and rearranging the code in various clever ways.

A good example can be found here.

This approach is not without its issues. Primarily, you cannot debug with the compressed JS, so it can be difficult to track down problems in the deployed code.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've also heard good things about the YUI JavaScript Compressor, but haven't used it myself yet.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear..I will have a look into these..!!!
 
John Walsh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Kumar wrote:Hi,

I have to render the user a jsp page and in the jsp page,there is a javascript called.Now this js file is of 100kb.I want to compress this file while sending it to the user.How can i do it??? I am using Websphere server.

Thanks in advance,


I recommend to use Granule Tag lib the http://code.google.com/p/granule/

It gzip and combine javascripts wrapped by g:compress tag

code sample is:
<pre>
<g:compress>
<script type="text/javascript" src="common.js"/>
<script type="text/javascript" src="closure/goog/base.js"/>
</script>
</g:compress>
...

</pre>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic