durehed / htmlcompressor

Automatically exported from code.google.com/p/htmlcompressor
Apache License 2.0
0 stars 0 forks source link

setCompressJavaScript(true) returned StringIndexOutOfBoundsException #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 brunocom...@gmail.com on 20 Aug 2010 at 10:19

GoogleCodeExporter commented 8 years ago
Does your javascript contain strings with html tags? Does it work without 
compressing javascript? Would you be able to provide html you are trying to 
compress?

Original comment by serg472@gmail.com on 24 Aug 2010 at 3:29

GoogleCodeExporter commented 8 years ago
I'm compressing javascript directly, with and without <script> </ script>

            function bozo(cocodeAranha) {
                alert(cocodeAranha);
            }

Original comment by brunocom...@gmail.com on 24 Aug 2010 at 4:03

GoogleCodeExporter commented 8 years ago
with and without <html> </html>

Original comment by brunocom...@gmail.com on 24 Aug 2010 at 8:25

GoogleCodeExporter commented 8 years ago
It wouldn't compress javascript directly. You need to use YUI compressor in 
this case.

So does it fail even when it is inside <script> tags? If you can provide a page 
that fails to compress that would be helpful. It is hard for me to figure out 
what's the problem right now.

Thanks.

Original comment by serg472@gmail.com on 25 Aug 2010 at 2:02

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I need to compress javascript directly due to the navigation ajax, here the 
script that it does not compress:
<script>

            function bozo(cocodeAranha) {
                alert(cocodeAranha);
            }
</ script>

It would not be a problem of Rhino library ?
http://yuilibrary.com/forum/viewtopic.php?f=94&t=3345

Thanks

Original comment by brunocom...@gmail.com on 25 Aug 2010 at 1:10

GoogleCodeExporter commented 8 years ago
The correct script

<script type=\"text/javascript\">
function bozo(cocodeAranha) {
   alert(cocodeAranha);
}
</script>

Original comment by brunocom...@gmail.com on 25 Aug 2010 at 1:30

GoogleCodeExporter commented 8 years ago
I will look over it on the weekend, thanks.

Why you don't want to use YUI compressor? It is what it was made for - to 
compress pure javascript. 

Original comment by serg472@gmail.com on 27 Aug 2010 at 5:27

GoogleCodeExporter commented 8 years ago
I used the YUICompressor 2.4.2, but returned same error .. I think the error is 
in it.

Original comment by brunocom...@gmail.com on 27 Aug 2010 at 2:53

GoogleCodeExporter commented 8 years ago
Sorry I can't reproduce this error. I tried to compress this code and it worked 
fine:

<script type=\"text/javascript\">
function bozo(cocodeAranha) {
   alert(cocodeAranha);
}
</script>

Are you getting error on trying to compress this exact piece of code? 

If you say that even YUI returns error then probably there is something wrong 
either with YUI or with javascript (tags are not closed or something like that).

I don't know what I can do here...

Original comment by serg472@gmail.com on 27 Aug 2010 at 9:23

GoogleCodeExporter commented 8 years ago
Really worked well here, but in a clean design, when I put it into my web 
project that uses SiteMesh and VRaptor it does not work, there would be any 
problem with another lib Rhino YUICompressor that implements different?

Original comment by brunocom...@gmail.com on 27 Aug 2010 at 9:40

GoogleCodeExporter commented 8 years ago
Sorry I haven't worked with any of those. Do you use standalone Rhino library 
in your project? I've seen a warning somewhere on YUI site that it conflicts 
with standalone Rhino as YUI already includes it and overwrites some of Rhino 
classes. 

Original comment by serg472@gmail.com on 27 Aug 2010 at 10:22

GoogleCodeExporter commented 8 years ago

Original comment by serg472@gmail.com on 26 Mar 2011 at 8:14