My working environment is:JSP,Struts 2.0,Ant based one build.xml,JS,HTML.
i want to compress my all js files as well remove all comments from that , so i need to one example of build.xml target , which help me to compress my all js files.
i had already goggling on it, i found the one jar based ant task example of htmlcompressor-1.5.3.jar.
it just compress my js files, not remove my comment portion from the js files.
i had try htmlcompressor-1.5.3.jar ant target with one simple js files only, Js file as below
when it compressed,that compressed file still contains this lines //alert('hy tested ok');,//document.getElmentByID('ping').value, in file,
what is meaning of this compression if it is not able to remove the comment portion from the js files,
and one more point i inform that i do not want to use this jar approach yuicompressor-2.4.6.jar.
i want any other solution which help me to compress the files , as well remove the comments from the js file also.
if anybody have other solution/approach/idea which help me to my issue.Then please share it with me.
for this problem you wont get specifc jar file but you need to write your own logic to replace the line from js file with Ant script.
You can use regex in ant script to remove the line which contains "//" ,try to make the script if you cant find the way let me know will send you the code ..
Joined: Jul 17, 2012
hi jatan bhavsar
first of thanks for the quick reply
here i have just given one types of comments only, it should be Single Line Comments,Multi-line Comments etc..
actually i don't want any types of comments in my compressed js files.So i can't going for the specific solution, is there any parameter option available for the my issue solution?Any option available in the htmlcompressor-1.5.3.jar. file use approach, one more time i say that i don't wan to use yuicompressor-2.4.6.jar approach.
if you can send me the code for the same, then please send me that code.
What you need is a "minifier". Google for it. There are several minifiers out there now. I think a really popular one is YUI minifier. YUI minifier provides a Java API. Some people have built ant tasks and maven plugins using the YUI minifier.