I think its because the first line is commented. When I see view source, the javascript line breaks are gone and therefore the entire javascript code is interpreted as a comment.
My suggestion: try removing the commented code or try block comments (/* */
)
I copy pasted the source to my local machine, converted the //
to /**/
and it seems to work (i admit, i just saw that things were better. I did not test).
Generally: If the javascript is compressed, by removing unnecessary spaces and new lines, avoid //
comments as much as possible
(but if some program (the webserver?) is compressing javascript by removing unnecessary whitespaces shouldn't it also remove the comments?)
EDIT:
To clarify: When I did view source in IE, I saw the javascript as a single looong line. In IE8's in-built source viewer (how do you call that?) and also when I copy pasted to Notepad
When I did view-source in Safari (Mac), the javascript was properly in different lines.
So:
no javascript compressing going on here as I mentioned before.
I suspect line endings. Do you develop on a non Windows machine, or is the editor on your windows machine configured to have a different line ending? (CR in place of CR/LF)
(anyway first try removing commented code to be sure. And then think about line endings)