Invalid characters in merged Javascript

210 views
Skip to first unread message

robertbeal

unread,
Oct 26, 2009, 10:26:50 AM10/26/09
to Juicer
Hi,

I'm merging a set of JavaScript files, but they're failing
YUICmpressor due to illegal characters.

These characters are occuring at the beginning of each file that is
stitched together in the .min output.

I have checked the original files though, and they look ok. I've made
sure they are UTF8 encoded, and opened them in Notepad, no illegal
characters.

So it appears these characters are being added during the merge.
Annoyingly it only happens on some JavaScript files (not had any
issues with .css). I'm basically trying to merge together a number of
jQuery plugins.

Would anyone be able to help out. I'm looking through the Juicer
source and libs. My Ruby is very basic though, I've only been using it
for the past couple of months (I'm a C# developer by profession).

robertbeal

unread,
Oct 26, 2009, 10:29:25 AM10/26/09
to Juicer
The command line output is along the lines of:

[ERROR] 517:2:illegal character

[ERROR] 517:2:syntax error

[ERROR] 517:3:illegal character

[ERROR] 1:0:Compilation produced 3 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 3
syntax errors
at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError
(YUICo
at org.mozilla.javascript.Parser.parse(Parser.java:410)
at org.mozilla.javascript.Parser.parse(Parser.java:355)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse
(JavaScr
2)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>
(JavaSc
33)
at com.yahoo.platform.yui.compressor.YUICompressor.main
(YUICompressor.j
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:
20)

And the character is:


robertbeal

unread,
Oct 26, 2009, 1:48:22 PM10/26/09
to Juicer
Sorry was a bit busy before, the above isn't the most helpful.

I've zipped up the files I'm trying to "juice". You can get them here:
http://www.robertbeal.com/wp-content/uploads/2009/10/juicer-invalid.zip

It should throw an error, and because of a
mysterious  character that seems to make it in the .min file

Christian Johansen

unread,
Oct 28, 2009, 3:52:07 AM10/28/09
to juice...@googlegroups.com
There seems to be some weird stuff in your files before Juicer touches them. For example, by using iconv, I was able to see the last line of jquery.defaultvalue.js as

})(jQuery);% 

There's obviously some character at the end there which you're seeing in the result. I'm suspecting the BOM - can you possibly try to resave the files as UTF-8 without the BOM?

Christian
--
MVH
Christian

robertbeal

unread,
Oct 30, 2009, 1:28:05 PM10/30/09
to Juicer
Ah cool cheers.

Weird I had tried saving them again in Notepad (which doesn't show the
character) as UTF8. So thought that wasn't the issue.

I'll try again just incase, make sure I do it to every file. Will let
you know the results. Maybe try a different editor too.


On Oct 28, 7:52 am, Christian Johansen <chrisj...@gmail.com> wrote:
> There seems to be some weird stuff in your files before Juicer touches them.
> For example, by using iconv, I was able to see the last line of
> jquery.defaultvalue.js as
>
> })(jQuery);%
>
> There's obviously some character at the end there which you're seeing in the
> result. I'm suspecting the BOM - can you possibly try to resave the files as
> UTF-8 without the BOM?
>
> Christian
>

robertbeal

unread,
Oct 30, 2009, 2:25:14 PM10/30/09
to Juicer
Haven't tried it just yet but pretty sure it'll work now. Had to
remove the BOM using Notepad++ (as seen in this post)

http://stackoverflow.com/questions/291455/xml-data-at-root-level-is-invalid

Christian Johansen

unread,
Oct 30, 2009, 6:17:09 PM10/30/09
to juice...@googlegroups.com
Glad it worked out. I guess a future version of Juicer should be able to detect the BOM and discard it/warn or do something about it.

Christian
--
MVH
Christian
Reply all
Reply to author
Forward
0 new messages