Take the 2-minute tour ×

I'm just about to freak out. I currently have to work on a website that some other guy did and I am asked to maintain etc. It uses jQuery and a bunch of drupal modules. At some point i get some syntax error, so that some js works, and some does not. My big big problem is to find the syntax error. Neither Firebug, nor WebInspector give me decent information:

Error: uncaught exception: Syntax error, unrecognized expression: //

Yeah… that's it. No lines, no filename, no more hints. Has anyone an idea how to deal with this?

Thanks for any usefull hints.

share|improve this question
I'm surprised that this is possible. Even if it was generated code that's being evaluated, eval() errors still are more informative than your example. –  Reinis I. Sep 10 '10 at 14:30

4 Answers 4

up vote 2 down vote accepted

you might try a tool like the closure compiler, which will give warnings and errors for blocks of code. otherwise, it's brute force with alert('checkpoint'); to determine how far into your code you get before things break.

share|improve this answer
I recommend using Firebug's console.log() instead of alert(), because closing the alert windows is annoying. –  Reinis I. Sep 10 '10 at 14:25

I believe Chrome's console pinpoints the line of the error.... Right-click on the page > Inspect element, then in the bottom right corner of the window that pops up, click on the red X icon, then click on the link for the error, enable Resource tracking if necessary...

Also, put the code trough JSLint and correct the code accordingly ...

share|improve this answer

I'd start by commenting out all but one javascript include at a time in the html, if possible (unless they're a tangled mess of dependencies). Other than that, can you try using a debugger to step through it line by line? Finally, if it's not too much work, maybe it's worth writing unit tests. It'll also help you fully understand the person's code, and probably identify any deeper logic-level bugs.

share|improve this answer
I just had a thought... maybe they used some obnoxiously unhelpful try-catch blocks... you know, of this sort: try { ... } catch (exception) { console.debug("there was an error.") } ... –  Aidan Brumsickle Sep 10 '10 at 14:31

JSLint may be what you need, but I bet it finds a lot more problems than just your elusive syntax error.

share|improve this answer

Your Answer


