liuzhe1218 / htmlcompressor Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/htmlcompressor
License: Apache License 2.0
Automatically exported from code.google.com/p/htmlcompressor
License: Apache License 2.0
What about to add replacement of " />" with "/>"
Example: <br /> - <br/>
Original issue reported on code.google.com by [email protected]
on 1 Dec 2009 at 9:45
What steps will reproduce the problem?
1. Add a JSP tag between <script> tags
2. Turn on JSP preservation pattern and Javascript compression
3. Compile HTML with step 1 done to it
What is the expected output? What do you see instead?
I'm getting an error as follows:
Apr 14, 2011 12:21:13 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: :15: ERROR - Parse error. syntax error
<%%%COMPRESS~USER0~0%%%>
What version of the product are you using? On what operating system?
version 1.2 on Windows Vista
Please provide any additional information below.
This looks like a thorny one. Closure Compiler doesn't like the placeholder but
something will be necessary. Perhaps wrapping the placeholder in an alert that
closure compiler will leave alone.
Original issue reported on code.google.com by [email protected]
on 14 Apr 2011 at 4:29
What steps will reproduce the problem?
1. use htmlcompressor v0.9.6
2. compress file containing HTML/inline CSS/inline Javascript, using options
follows:
--type html --charset utf-8 --remove-quotes --remove-intertag-spaces \
--compress-js --compress-css --line-break 254
2. compress same file with v0.9.3
3. Compare output
What is the expected output? What do you see instead?
EXPECTED to see new version compress as well or better than old, compressing
HTML, CSS and JS.
INSTEAD, new version fails to compress CSS and fails to compress Javascript.
Only HTML is compressed.
Older htmlcompressor saves ~3000 bytes; new version saves ~150 bytes
What version of the product are you using? On what operating system?
htmlcompressor-0.9.6.jar, yuicompressor-2.4.2.jar
OS: Mac OS 10.6.5
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)
Please provide any additional information below.
Sample command line session
NOTE: v0.9.6 does NOT compress file that v0.9.3 does, w/same options.
Notice size of 'tel-compressed-093.html. Compression with v0.9.6 saves ~150
bytes, compression with older version saves ~3000 bytes.
$ls -Fsal
total 1880
0 drwxr-xr-x 7 tkuser staff 238 Dec 12 20:32 ./
0 drwxrwxr-t 37 root admin 1326 Dec 12 20:31 ../
16 -rw-r--r--@ 1 tkuser staff 6148 Dec 12 20:30 .DS_Store
80 -rw-------@ 1 tkuser staff 37620 Oct 30 19:44 htmlcompressor-0.9.3.jar
80 -rw-r--r--@ 1 tkuser staff 39485 Dec 12 17:54 htmlcompressor-0.9.6.jar
40 -rw-r--r-- 1 tkuser staff 19472 Dec 12 20:10 tel.html
1664 -rw-r--r--@ 1 tkuser staff 851219 Nov 14 2008 yuicompressor-2.4.2.jar
$java -jar htmlcompressor-0.9.3.jar --type html --charset utf-8 --remove-quotes
--remove-intertag-spaces --compress-js --compress-css --line-break 254 tel.html
-o tel-compressed-093.html
$java -jar htmlcompressor-0.9.6.jar --type html --charset utf-8 --remove-quotes
--remove-intertag-spaces --compress-js --compress-css --line-break 254 tel.html
-o tel-compressed-096.html
$ls -Fsal
total 1960
0 drwxr-xr-x 9 tkuser staff 306 Dec 12 20:34 ./
0 drwxrwxr-t 37 root admin 1326 Dec 12 20:31 ../
16 -rw-r--r--@ 1 tkuser staff 6148 Dec 12 20:30 .DS_Store
80 -rw-------@ 1 tkuser staff 37620 Oct 30 19:44 htmlcompressor-0.9.3.jar
80 -rw-r--r--@ 1 tkuser staff 39485 Dec 12 17:54 htmlcompressor-0.9.6.jar
40 -rw-r--r-- 1 tkuser staff 16462 Dec 12 20:33 tel-compressed-093.html
40 -rw-r--r-- 1 tkuser staff 19319 Dec 12 20:34 tel-compressed-096.html
40 -rw-r--r-- 1 tkuser staff 19472 Dec 12 20:10 tel.html
1664 -rw-r--r--@ 1 tkuser staff 851219 Nov 14 2008 yuicompressor-2.4.2.jar
Original issue reported on code.google.com by [email protected]
on 13 Dec 2010 at 5:09
Attachments:
What steps will reproduce the problem?
1. Add some javascript in your file like google suggests
2. render the compressed jsp
What is the expected output?
I expect google website optimizer to work
What do you see instead?
Google website optimizer says your code is invalid, I expected var n=... but I
saw var l=...
What version of the product are you using?
0.9.1
On what operating system?
OSX, Linux
Please provide any additional information below.
Here is an example exceprt from wso:
<script>utmx_section("searchbox")</script>
// Section of page to be variant tested
</noscript>
The noscript marks the end of the section in question. There is no open tag
for the noscript only a close tag.
Original issue reported on code.google.com by jeff%[email protected]
on 7 Jun 2010 at 10:08
I am working on a project that runs on an embedded platform and uses jsp pages
for the web interface. These jsp pages are precompiled into servlets as part of
the build process. I would like to use htmlcompressor to compress these jsp
pages before compiling them into servlets. I know that the recommended practice
is to instead compress the resulting html "on the fly", but this not feasible
due to resource constrains on the target platform.
I believe this could easily be achieved by just having htmlcompressor preserve
<% ... %> and <jsp: ... > blocks. This would be more than enough, at least for
simple use cases such as the one described.
Original issue reported on code.google.com by [email protected]
on 25 Aug 2010 at 9:13
It seems Gmail does it and I think it's worth the effort (eg. #foo -> #a, #bar
-> #b, .baz -> .a). I do know though, that it might be difficult to implement.
Original issue reported on code.google.com by [email protected]
on 17 Jul 2011 at 12:57
New lines should be replaced with spaces on Linux to be consistent with Windows
results.
Original issue reported on code.google.com by [email protected]
on 17 Mar 2011 at 5:56
What steps will reproduce the problem?
1. Compress a html file with the following in it:
<script>
var t='<textarea ' + '></textarea>';
</script>
What is the expected output? What do you see instead?
I expect it to do nothing, it instead:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at
java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:797)
at java.lang.StringBuilder.replace(StringBuilder.java:271)
at
com.googlecode.htmlcompressor.compressor.HtmlCompressor.returnBlocks(HtmlCompres
sor.java:163)
at
com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.
java:107)
at cmdlinehtml.main(cmdlinehtml.java:40)
What version of the product are you using? On what operating system?
htmlcompressor-0.7.jar
Please provide any additional information below.
Thanks for htmlcompressor!
Joe
Original issue reported on code.google.com by [email protected]
on 20 Sep 2009 at 4:54
<link rel=stylesheet type="text/css" ...
<script type="text/script" ... (or application/javascript)
<style type="text/style" ...
Those three elements do not need the type attribute as long as it is those
values.
Thanks! love the project.
Original issue reported on code.google.com by [email protected]
on 19 Mar 2011 at 7:36
[deleted issue]
Error in compressor js:
# java -jar /home/user/workspace/inel/intranet/js/htmlcompressor-0.8.2.jar
--compress-js --compress-css index.phtml -o index.min.phtml
java.lang.NullPointerException
at org.mozilla.javascript.Parser.addError(Parser.java:146)
at org.mozilla.javascript.Parser.reportError(Parser.java:160)
at org.mozilla.javascript.Parser.primaryExpr(Parser.java:2464)
at org.mozilla.javascript.Parser.memberExpr(Parser.java:1950)
at org.mozilla.javascript.Parser.unaryExpr(Parser.java:1808)
at org.mozilla.javascript.Parser.mulExpr(Parser.java:1737)
at org.mozilla.javascript.Parser.addExpr(Parser.java:1718)
at org.mozilla.javascript.Parser.shiftExpr(Parser.java:1698)
at org.mozilla.javascript.Parser.relExpr(Parser.java:1672)
at org.mozilla.javascript.Parser.eqExpr(Parser.java:1628)
at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:1617)
at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:1606)
at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:1595)
at org.mozilla.javascript.Parser.andExpr(Parser.java:1583)
at org.mozilla.javascript.Parser.orExpr(Parser.java:1571)
at org.mozilla.javascript.Parser.condExpr(Parser.java:1554)
at org.mozilla.javascript.Parser.assignExpr(Parser.java:1539)
at org.mozilla.javascript.Parser.condExpr(Parser.java:1558)
at org.mozilla.javascript.Parser.assignExpr(Parser.java:1539)
at org.mozilla.javascript.Parser.expr(Parser.java:1518)
at org.mozilla.javascript.Parser.statementHelper(Parser.java:1201)
at org.mozilla.javascript.Parser.statement(Parser.java:708)
at org.mozilla.javascript.Parser.parse(Parser.java:401)
at org.mozilla.javascript.Parser.parse(Parser.java:359)
at
com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompresso
r.java:312)
at
com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompress
or.java:533)
at
com.googlecode.htmlcompressor.compressor.HtmlCompressor.compressJavaScript(HtmlC
ompressor.java:257)
at
com.googlecode.htmlcompressor.compressor.HtmlCompressor.processScriptBlocks(Html
Compressor.java:236)
at
com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.
java:109)
at
com.googlecode.htmlcompressor.CmdLineCompressor.main(CmdLineCompressor.java:200)
HTML in attach
Original issue reported on code.google.com by [email protected]
on 8 Dec 2009 at 6:32
Attachments:
I'd love to see image compression added to your already excellent lib. You
already compress html, css, and js, so why not images as well? Images are some
of the biggest resource hogs on a website, so they're a good candidate for
inclusion. I'm thinking it could be as simple as adding support for tools like
pngcrush (or any other PNG optimizer tool) and/or jpegtran for JPEGs. You
already include external dependencies for yuicompressor, so adding these other
tools shouldn't be that much of a stretch. Or, am I wrong? I've been looking
for an all around solution for quite some time now... and you're lib is the
only one that even comes close (besides google's mod_pagespeed which I can't
use).
Original issue reported on code.google.com by [email protected]
on 28 Mar 2011 at 8:34
If I try to run htmlcompressor from command line I get:
java -jar htmlcompressor-0.9.2.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
org/mozilla/javascript/ErrorReporter
at com.googlecode.htmlcompressor.CmdLineCompressor.main(CmdLineCompressor.java:145)
Caused by: java.lang.ClassNotFoundException:
org.mozilla.javascript.ErrorReporter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Seems that it needs Rhino, I downloaded it and if I try running htmlcompressor
again it happens the same:
java -classpath js.jar -jar htmlcompressor-0.9.2.jar
...leads to the same result
Original issue reported on code.google.com by [email protected]
on 2 Sep 2010 at 4:20
Hi. Thanks for the library!
When setRemoveComments(true) then compressor removes also Conditional
Comments (http://www.quirksmode.org/css/condcom.html) for IE.
Original issue reported on code.google.com by [email protected]
on 7 Jul 2009 at 6:24
What steps will reproduce the problem?
1. grab attached test.html
2. java -jar htmlcompressor-1.4.1.jar --compress-js --preserve-php test.html
What is the expected output?
Minified HTML with the inline php in tact.
What do you see instead?
This error:
[ERROR] HtmlCompressor: "unterminated string literal" at line [1:30] during
JavaScript compression: js/libs/modernizr-2.0.min.js">
[ERROR] HtmlCompressor: "syntax error" at line [1:30] during JavaScript
compression: js/libs/modernizr-2.0.min.js">
[ERROR] HtmlCompressor: "Compilation produced 2 syntax errors." at line [1:0]
during JavaScript compression
org.mozilla.javascript.EvaluatorException: Compilation produced 2 syntax errors.
at com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor$DefaultErrorReporter.runtimeError(YuiJavaScriptCompressor.java:93)
at org.mozilla.javascript.Parser.parse(Parser.java:392)
at org.mozilla.javascript.Parser.parse(Parser.java:337)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:533)
at com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.compress(YuiJavaScriptCompressor.java:53)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compressJavaScript(HtmlCompressor.java:837)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processScriptBlocks(HtmlCompressor.java:772)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processPreservedBlocks(HtmlCompressor.java:662)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.java:193)
at com.googlecode.htmlcompressor.CmdLineCompressor.main(CmdLineCompressor.java:349)
Thanks! Really like the new statistics stuff.
Original issue reported on code.google.com by [email protected]
on 31 Jul 2011 at 1:37
Attachments:
Hello
Please create OSGi bundle from your jar. You can use Bnd tool to do this. See
http://www.aqute.biz/Bnd/Ant or http://www.aqute.biz/Bnd/Maven.
Thanks in advance
Original issue reported on code.google.com by [email protected]
on 3 May 2011 at 1:44
They can be recognized by the rel=external attribute in <a> and <link>.
Original issue reported on code.google.com by [email protected]
on 10 Aug 2011 at 4:28
What steps will reproduce the problem?
1. If i build and i have yuicompressor-2.4.5.jar in the same folder as
htmlcompressor-0.9.9.jar I get an error.
What is the expected output? What do you see instead?
I get this:
[apply] ERROR: For JavaScript or CSS compression YUI compressor jar file
[apply] must be present in the same directory as HtmlCompressor jar
[apply] Result: 1
Everything works fine with yuicompressor-2.4.2.jar
I suppose there is a max version set somewhere?
We are forced to upgrade because there is a bug in yuicompressor's css thing
that makes this:
@media screen and (max-device-width: 480px){
into this
@media screen and(max-device-width: 480px){
But it turns out there is a webkit bug that tosses out the whole MQ if that
space is not present before the (
And 2.4.2 has this bug.. (but I think its fixed as of 2.4.3.. definitely fixed
in my recently built 2.4.5)
So I suppose this bug is also fair warning the htmlcompressor's built in CSS
minifier may also have this bug. :)
Original issue reported on code.google.com by [email protected]
on 23 Mar 2011 at 1:24
JSP 2.0 does not require tag lib declaration in web.xml file. You can also
bundle tag lib tld files with jars instead of having a separate download and
JSP container will find the tld file automatically.
More info:
http://wiki.metawerx.net/wiki/RemovingTaglibFromWeb.xml
Original issue reported on code.google.com by [email protected]
on 12 Nov 2010 at 11:09
It would be nice to have a tool that could provide some statistics and
suggestions on compression settings for a particular case.
For now it would be probably a command line only tool with plain text output.
In the first release it would simply display a list of page size gains using
different compression settings.
In the future it would be nice to have something that would also suggest which
compression settings to use and some refactoring recommendations on not
efficient HTML blocks from the page size point of view.
Please leave your thoughts and ideas for improvement in this thread.
Original issue reported on code.google.com by [email protected]
on 10 Apr 2011 at 5:29
Overview
========
Currently all occurrences of whitespace are replaced with a single space
character in the compressed markup. This generally results in a one long line
that is very difficult for a human to read.
If certain whitespace sequences were condensed to a line feed instead of a
space, the result would be considerably more readable. Obviously this should
not happen to every whitespace sequence, as that would be even less readable
than the current implementation.
I propose condensing whitespace sequences to a line feed only if there is at
least one newline (a line feed or carriage return) in it already.
Example
=======
<ul>
<li>Foo</li>
<li>Bar <em>baz</em></li>
</ul>
Instead of:
<ul> <li>Foo</li> <li>Bar <em>baz</em></li> </ul>
Becomes:
<ul>
<li>Foo</li>
<li>Bar <em>baz</em></li>
</ul>
Considerations
==============
1) The line feed character is not universally recognised as a new line. Presumably it *is* recognised as whitespace by all major browers on all platforms. If this assumption turns out to be false this feature request falls somewhat flat.
2) The behaviour will not be desirable to all, and adding the check for an existing newline necessarily slows down the compression (at least slightly), so it should be optional.
3) The behaviour may not be wanted in certain situations, e.g., inside an element or attribute:
<div class="container"
style="color: lime;
background-color: magenta"></div>
4) Humans are not the intended target of this application. As source if readily viewable to end users, though, it would be considerate.
Original issue reported on code.google.com by [email protected]
on 27 Jun 2011 at 4:06
Hello. What about to add possibility to replace css and javascript compressor?
Add some interfaces and config options like CSSCompressorClass and
JSCompressorClass...?
I use google closure compiler and don't like yahoo compressor (some versions
has bugs, with 2.4.4 I get StackOverflowException).
P.S. Sorry for my English.
Original issue reported on code.google.com by [email protected]
on 11 Mar 2011 at 10:17
htmlcompressor removes also nonredundant whitespaces. For example:
<b>hello</b> <i>world</i>
will become
<b>hello</b><i>world</i>
Original issue reported on code.google.com by [email protected]
on 3 May 2011 at 2:06
Some software generates XHTML Source Code
like
<input type="submit"/>
then compress it with compressor.setRemoveQuotes(true);
the result is <input type=submit/>
in the browser the button disappears, a textfield appears instead
a workaround would be <input type=submit />
version: htmlcompressor-0.9.4
Original issue reported on code.google.com by [email protected]
on 3 Dec 2010 at 10:54
I use jQuery templating and the recommendation is to wrap the template within
script tags of type "text/x-jquery-tmpl".
htmlcompressor - rightly - leaves such script blocks uncompressed but, since
the templates are well-formed HTML, they could be compressed if only there were
a way to instruct htmlcompressor not to avoid them.
I appreciate that this is possible using the existing API but I'm not much of a
Java developer :-)
Perhaps a flag --compress-jquery-script-template?
Thanks for providing a useful tool!
Original issue reported on code.google.com by [email protected]
on 16 Jul 2011 at 2:26
htmlcompressor removes SSI from the files, so for example, if I have the
following construct in index.html:
<!--# set var="page" value="index" -->
<!--# include file="_before.html" -->
<p>blabla</p>
<!--# include file="_after.html" -->
It treats all the <!--# and <!-- # comments like normal other HTML comments.
There should be an exception in the htmlcompressor for comments starting with a
'#' or 'whitespace #' to retain the SSI in the minified files.
Original issue reported on code.google.com by [email protected]
on 29 Jun 2011 at 11:16
For example, if you minify the html from www.html5boilerplate.com:
<!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie7"> <![endif]-->
<!--[if IE 8 ]> <body class="ie8"> <![endif]-->
<!--[if IE 9 ]> <body class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]-->
becomes
<!--[if lt IE 7 ]><body class="ie6"><![endif]--><!--[if IE 7 ]><body
class="ie7"><![endif]--><!--[if IE 8 ]><body class="ie8"><![endif]--><!--[if IE
9 ]><body class="ie9"><![endif]--><!--[if (gt IE 9)|!(IE)]>
Original issue reported on code.google.com by [email protected]
on 30 Aug 2010 at 10:00
What steps will reproduce the problem?
1. compress html that contains russian utf8 char "И" (D0 98)
What is the expected output? What do you see instead?
Hmmm. Expected the same char (D0 98) without any modifications, but (D0 F3)
appears instead
What version of the product are you using? On what operating system?
win7 x64, Java(TM) SE Runtime Environment (build 1.6.0_22-b04),
htmlcompressor-0.9.8.jar
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 6 Jan 2011 at 2:12
Hi. What about to add support of Javascript optimisation with Google
Closure Compiler (http://code.google.com/intl/it/closure/compiler/) and
freemarker template engine?
What version of the product are you using? On what operating system?
htmlcompressor 0.8, linux
Original issue reported on code.google.com by [email protected]
on 27 Nov 2009 at 9:57
According to the HTML 4.01 specification whitespace at the beginning and the
end of a tag can be removed and multiple whitespace characters can be
compressed into a single character.
However, htmlcompressor doesn't handle whitespace correctly:
$ cat t.html
<html>
<head>
<title>foobar</title>
</head>
<body>
<p>
<span>foo</span>
<span>bar</span>
</p>
</body>
</html>
$ java -jar htmlcompressor-0.9.3.jar t.html
<html> <head> <title>foobar</title> </head> <body> <p> <span>foo</span>
<span>bar</span> </p> </body>
$ java -jar htmlcompressor-0.9.3.jar --remove-intertag-spaces
<html><head><title>foobar</title></head><body><p><span>foo</span><span>bar</span
></p></body></html>
Both outputs are incorrect. The correct version would be:
<html><head><title>foobar</title></head><body><p><span>foo</span>
<span>bar</span></p></body>
Original issue reported on code.google.com by [email protected]
on 24 Sep 2010 at 11:50
Hi.
Sometimes I using html comment to get w3c valid constuction like:
<someTag><!--//--></someTag>
But if I remove all html comments I get validator error.
Is it possible add some rule for this?
Thanks.
Original issue reported on code.google.com by [email protected]
on 19 Feb 2010 at 8:19
Is there a version I can run from the command line, instead of from Java code?
Original issue reported on code.google.com by [email protected]
on 4 Nov 2009 at 8:16
Would be nice to have some documentation on how to use the library with Java
Facelets. Now I can't make it working..
Original issue reported on code.google.com by yegor256
on 2 Aug 2010 at 1:12
I am implementing a Servlet Filter to create a JSON object to navigation and
AJAX to compress a piece of html setCompressJavaScript(true), the error is
returned StringIndexOutOfBoundsException
What is the expected output? What do you see instead?
Compressed html and in-line js
What version of the product are you using? On what operating system?
0.9.1 Windows 7 or ubuntu linux
Original issue reported on code.google.com by [email protected]
on 20 Aug 2010 at 10:19
What steps will reproduce the problem?
1. The script is compressed but, rename the tags value, checked, etc
2. If I put the same javascript in a file and use closure compress, it maintain
the tags name.
3. The compilation_level is ADVANCED_OPTIMIZATIONS.
The version of htmlcompressor is 1.3, and the closure is 1.2.
What is the expected output? What do you see instead?
o("i18").value = parseInt(c[3], 10);
o("i13").value = parseInt(c[4], 10);
and do:
o("i18").a=parseInt(c[3],10);
o("i13").a=parseInt(c[4],10);
The OS version is Ubuntu 10.04
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 25 Apr 2011 at 3:14
What steps will reproduce the problem?
1. Created html containing string "Français"
2. Run HTML compressor with or without charset UTF-8 option
What is the expected output? What do you see instead?
"Français" is stored as "Français"
What version of the product are you using? On what operating system?
htmlcompressor-1.4.2.jar
Please provide any additional information below.
using JAVA 1.5 update 15 on Windows XP SP3
Original issue reported on code.google.com by [email protected]
on 2 Aug 2011 at 10:56
Would be nice to have an ability to use the library as maven resource. Instead
of copying `.tld` file into `WEB-INF` I would include a dependency in `pom.xml`.
Original issue reported on code.google.com by yegor256
on 2 Aug 2010 at 1:06
What steps will reproduce the problem?
1. Include Javascript with CDATA in HTML Document (Style 2, see coming text)
2. Compress HTML Document with Html Compressor
3. Javascript is not compressed
What version of the product are you using? 0.9
Hi there,
according to the W3C xHTML Specification (http://www.w3.org/TR/xhtml1/ ,
section 4.8) Javascript should be put into cdata to validate successfully:
<script type="text/javascript">
<![CDATA[
... unescaped script content ...
]]>
</script>
To avoid confusing older browsers the cdata tags are often put into
comments like:
Style 1:
<script type="text/javascript">
/* <![CDATA[ */
... unescaped script content ...
/* ]]> */
</script>
or
Style2:
<script type="text/javascript">
//<![CDATA[
... unescaped script content ...
//]]>
</script>
It would be very nice for htmlcompressor to adhere script put into cdata.
Original issue reported on code.google.com by [email protected]
on 6 Feb 2010 at 11:32
There is insufficient documentation for compress:js. I'm trying to determine
if it will meet the needs of my project.
The most detailed mention of compress:js that I can find within this project is
as follows:
<compress:js enabled="true" yuiJsLineBreak="80"
yuiJsPreserveAllSemiColons="true"></compress:js>
But how do I specify source files? Can I specify multiple source files? Or
does it (only) work with inline Javascript?
I am impressed with how active this project is but until I get answers to the
above questions I cannot use it in my work. On the other hand, for the time
being I am using another project, though it is much less active than yours.
And this is the documented interface for compressing multiple js files:
<pack:script>
<src>/js/myJavaScriptFile.js</src>
<src>/js/mySecondJavaScriptFile.js</src>
</pack:script>
This is more or less the type of interface within the JSP that I'd like to be
able to use. Problem is, this other project does not rely on YuiCompressor,
and therefore fails on some regular expression literals.
So I'd much prefer to use htmlcompressor since it relies on yuicompressor. But
first I need to better understand if/how to combine multiple javascript files
from within the JSP. And I think any explanation you can provide me, might be
good documentation for your home page as well.
Thanks!!
Original issue reported on code.google.com by [email protected]
on 18 Mar 2011 at 3:00
>> What steps will reproduce the problem?
1. Use htmlcompressor-0.9.7.jar with yuicompressor-2.4.4.jar
2. Set --compress-js or compress-css
3. Run
>> What is the expected output? What do you see instead?
No errors should be reported and Javascript and CSS within the HTML files
should also be compressed.
Instead, I see an error relating to how the yuicompressor-2.4.2.jar must be in
the same directory in order for htmlcompressor to find it, regardless of
version. Also, no HTML was compressed at all, while it might be expected that
html would be compressed while the --compress-js / css options would simply be
ignored and HTML compression would continue.
>> Please provide any additional information below.
YUI Compressor 2.4.2 had a serious bug which munged CSS media queries
(http://yuilibrary.com/projects/yuicompressor/ticket/2527991) and was fixed in
2.4.4 which is still not up on the Public YUI download page.
The overview of this project mentions that the filename of yuicompressor cannot
be configured.
Perhaps scanning the filesystem only in the same directory as htmlcompressor
and looking for any version of yuicompressor would work better. To workaround,
I've simply renamed the newer yuicompressor (probably should patch my local src
with the newer yuicompressor filename).
-----
Thanks, Serg; this compressor is really great!
Original issue reported on code.google.com by [email protected]
on 29 Dec 2010 at 1:28
compress a large jsp page (e.g. 2MBytes) leads to messed up html code with
%%%COMPRESS~EVENT~1.000%%% to %%%COMPRESS~EVENT~11.687%%% fragments in the ouput
caused by HtmlCompressor:preserveBlocks
calls of java.text.MessageFormat.format("%%%COMPRESS~EVENT~{0}%%%", new
Object[] {Integer.valueOf(index)})
have to be MessageFormat.format("%%%COMPRESS~EVENT~{0,number,#}%%%", new
Object[] {Integer.valueOf(index)})
can be reproduced with this sample code
for(int index=995; index< 1005; index++){
// all COMPRESS~???~ patterns are wrong for i>=1000 (at least in HtmlCompressor.java)
String bad = java.text.MessageFormat.format("%%%COMPRESS~EVENT~{0}%%%" , new Object[] {Integer.valueOf(index)});
String good = java.text.MessageFormat.format("%%%COMPRESS~EVENT~{0,number,#}%%%", new Object[] {Integer.valueOf(index)});
System.out.println("bad: "+bad +", good:" +good);
}
with corrected code in HtmlCompressor, html output is good
Original issue reported on code.google.com by [email protected]
on 2 Feb 2011 at 8:31
How can we use block preservation rules in when calling HTMLCompressor from an
Ant build OR from a windows batch file?
I need to add a block preservation rule but I can not work out if it is
possible.
Please help.
Thanks,
Mark.
By the way HTMLCompressor is a good piece of work. Well Done.
Original issue reported on code.google.com by [email protected]
on 6 Dec 2010 at 7:53
First, I'd like to say that this is a great lib and I'm so thankful for it.
Please keep up the good work. Now, onto my problem...
What steps will reproduce the problem?
1. Upgrade JAR to version 1.1
2. Add any of the new "remove*" attributes to compress:html TLD tag
3. Run webpage (and View Source if you can) to see output
What is the expected output? What do you see instead?
I expected the page to render and successfully compress/minify HTML code (as it
did before using earlier versions). However, I got a blank page due to the
below error.
What version of the product are you using? On what operating system?
I'm using version 1.1 of JAR in Windows XP/Eclipse environment
Please provide any additional information below.
Mar 28, 2011 4:09:27 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /common/templates/default/index.jsp(11,0)
Attribute removeInputAttributes invalid for tag html according to TLD
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1235)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:846)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:650)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:644)
at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:126)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:149)
at org.apache.struts.tiles.taglib.InsertTag.doInclude(InsertTag.java:761)
at org.apache.struts.tiles.taglib.InsertTag$InsertHandler.doEndTag(InsertTag.java:893)
at org.apache.struts.tiles.taglib.InsertTag.doEndTag(InsertTag.java:462)
at org.apache.jsp.index_jsp._jspx_meth_tiles_005finsert_005f0(index_jsp.java:169)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:95)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.spafinder.cms.request.RequestFilter.doFilter(RequestFilter.java:103)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.spafinder.servlet.filter.EncodingFilter.doFilter(EncodingFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.spafinder.cms.request.VanityUrlFilter.doFilter(VanityUrlFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:407)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Original issue reported on code.google.com by [email protected]
on 28 Mar 2011 at 8:20
What steps will reproduce the problem?
1. get attached test.html
2. java -jar htmlcompressor-1.4.2.jar --preserve-php test.html
What is the expected output?
Minified output, with the php tag retained
What do you see instead?
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.returnBlocks(HtmlCompressor.java:463)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.java:196)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.preserveBlocks(HtmlCompressor.java:277)
at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.java:187)
at com.googlecode.htmlcompressor.CmdLineCompressor.main(CmdLineCompressor.java:349)
Original issue reported on code.google.com by [email protected]
on 31 Jul 2011 at 6:54
Attachments:
The files would be named in the CLI, minified, compressed, and included as
*inline* CSS/JS.
Original issue reported on code.google.com by [email protected]
on 10 Jul 2011 at 11:56
I've noticed many sites uses 'http://' to start external links when '//' is
shorter and seems to work fine cross-browser.
Original issue reported on code.google.com by [email protected]
on 13 Apr 2011 at 5:48
With Default settings compress the attached html file.
You end up with the following:
"This line getssmooshed together"
A missing space between "gets" and "smooshed".
Original issue reported on code.google.com by [email protected]
on 30 Mar 2010 at 11:04
Attachments:
What steps will reproduce the problem?
1. use htmlcompressor v0.9.6
2. compress file containing HTML/inline CSS/inline Javascript, using options
follows:
--type html --charset utf-8 --remove-quotes --remove-intertag-spaces \
--compress-js --compress-css --line-break 254
2. compress same file with v0.9.3
3. Compare output
What is the expected output? What do you see instead?
EXPECTED to see new version compress as well or better than old, compressing
HTML, CSS and JS.
INSTEAD, new version fails to compress CSS and fails to compress Javascript.
Only HTML is compressed.
What version of the product are you using? On what operating system?
htmlcompressor-0.9.6.jar, yuicompressor-2.4.2.jar
OS: Mac OS 10.6.5
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)
Please provide any additional information below.
Sample command line session
NOTE: v0.9.6 does NOT compress file that v0.9.3 does, w/same options
$ls -Fsal
total 1880
0 drwxr-xr-x 7 tkuser staff 238 Dec 12 20:32 ./
0 drwxrwxr-t 37 root admin 1326 Dec 12 20:31 ../
16 -rw-r--r--@ 1 tkuser staff 6148 Dec 12 20:30 .DS_Store
80 -rw-------@ 1 tkuser staff 37620 Oct 30 19:44 htmlcompressor-0.9.3.jar
80 -rw-r--r--@ 1 tkuser staff 39485 Dec 12 17:54 htmlcompressor-0.9.6.jar
40 -rw-r--r-- 1 tkuser staff 19472 Dec 12 20:10 tel.html
1664 -rw-r--r--@ 1 tkuser staff 851219 Nov 14 2008 yuicompressor-2.4.2.jar
$java -jar htmlcompressor-0.9.3.jar --type html --charset utf-8 --remove-quotes
--remove-intertag-spaces --compress-js --compress-css --line-break 254 tel.html
-o tel-compressed-093.html
$java -jar htmlcompressor-0.9.6.jar --type html --charset utf-8 --remove-quotes
--remove-intertag-spaces --compress-js --compress-css --line-break 254 tel.html
-o tel-compressed-096.html
$ls -Fsal
total 1960
0 drwxr-xr-x 9 tkuser staff 306 Dec 12 20:34 ./
0 drwxrwxr-t 37 root admin 1326 Dec 12 20:31 ../
16 -rw-r--r--@ 1 tkuser staff 6148 Dec 12 20:30 .DS_Store
80 -rw-------@ 1 tkuser staff 37620 Oct 30 19:44 htmlcompressor-0.9.3.jar
80 -rw-r--r--@ 1 tkuser staff 39485 Dec 12 17:54 htmlcompressor-0.9.6.jar
40 -rw-r--r-- 1 tkuser staff 16462 Dec 12 20:33 tel-compressed-093.html
40 -rw-r--r-- 1 tkuser staff 19319 Dec 12 20:34 tel-compressed-096.html
40 -rw-r--r-- 1 tkuser staff 19472 Dec 12 20:10 tel.html
1664 -rw-r--r--@ 1 tkuser staff 851219 Nov 14 2008 yuicompressor-2.4.2.jar
Original issue reported on code.google.com by [email protected]
on 13 Dec 2010 at 4:54
What steps will reproduce the problem?
Compress the following html:
<!--<option value='same'><script
type="text/javascript">document.write('hi');</script>-->
What is the expected output? What do you see instead?
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at
java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:79
7)
at java.lang.StringBuilder.replace(StringBuilder.java:271)
at
com.googlecode.htmlcompressor.compressor.HtmlCompressor.returnBlocks(
HtmlCompressor.java:172)
at
com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(Html
Compressor.java:107)
at cmdlinehtml.main(cmdlinehtml.java:40)
htmlcompressor.0.7.1 windows
Original issue reported on code.google.com by [email protected]
on 29 Sep 2009 at 10:50
Currently you can define as many preservation rules as you like, but it
requires a bit of extra work.
I am thinking a good addition would be to create some simple syntax that would
tell HTML compressor to skip following block. Currently I am leaning towards:
<!-- {{{ -->
- Anything inside will be preserved, with the highest priority after user defined blocks
- Number of spaces around {{{ could be zero or more
- These comments themselves will be always removed ignoring comment removal setting
<!-- }}} -->
Making it an HTML comment would ensure that having it on a page wouldn't break
anything even if HTML compressor is not applied to the page.
Now a few questions for you:
- What do you think about such syntax? Could it interfere with any other
scripting language?
- Should this syntax have the higher priority over user defined rules or not? I
think user defined rules still should be at the top as if you went through the
trouble of defining them then you should know what you are doing.
- Should these comments be treated as regular comments during compression and
removed with the rest of the comments if set so, or always removed?
Original issue reported on code.google.com by [email protected]
on 10 Apr 2011 at 4:56
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.