SquishIt javascript error when minimized: 'missing ; before statement' - javascript

When I run SquishIt in development mode everything works fine. When I put it into production mode I am getting the 'missing ; before statement' error in Javascript. I've tried removing the offending javascipt files, but the error moves down to the next one.
Any idea's?

One possibility is that you're missing a ; somewhere in your code that's being automatically inserted by the browser. Use jslint to find the offending lines of code.

I also posted this problem on the Squishit google groups. Justin reponded:
This is a known bug that is going to
be fixed in an soon to be released
SquishIt 0.6.1. Essentially the ajax
minifier is compressing the files
separately before we are combining
them into one. This can cause the
issue you are seeing. The fix in the
meantime is to use the WithCompressor
option and switch to something like
the YUI compressor temporarily.the YUI compressor temporarily.
Bundle.JavaScript()
.Add("/Scripts/Frameworks/jquery.js").WithMinifier(JavaScriptMinifiers.Yui)
....

Related

How can I add new syntax to an existing language in Netbeans IDE 16?

Netbeans considers for await syntax to be invalid. The error hint indicates: "Expected ( but found await". Source > Format will not work as expected while the for await remains.
Is there a way to update the existing syntax checker for .js files to mark for await as valid syntax, so that the code formatter will work correctly again?
I tried to review FAQs on the official site for Netbeans. All the relevant questions lead to page not found dead ends.
I tried to go to Tools > Options > Miscellaneous > Files to edit the associated file config for js which defaults to text/karmaconf+javascript. It's possible to change the file type, but not to edit the existing one. I searched the netbeans program files path for the config file to update it manually, but I don't quite know how to find it.
I can reproduce your issue in NetBeans 16, and it has already been bug reported. See NetBeans Bug Report #4757 JavaScript to support "for await of" #4757.
You could opt to filter out the parsing error:
However, that approach would probably cause more problems that it would solve. While it would make that "Expected ( but found await" message go away, at a minimum it would also impact the parsing of the entire file, and would not impact formatting at all. (I realize that was not part of your question, and mention it only for completeness.)
Apart from that, all you can really do is update the bug report to voice your concern in the hope that it increases the priority of fixing the bug.
Unfortunately I don't see any way to resolve the issue through configuration changes in NetBeans.

How can I find an error in the minified version of a script with no errors?

I just launched a website that uses version 2.2 of the FlexSlider library. If you go to that page, you'll see a Javascript error with an unhelpful message:
TypeError: 'undefined' is not a function (near '...Animate(t,true)}}}})(jQuery)...')
or if you're in Firefox:
TypeError: (intermediate value)(...) is not a function
...{u=""},3e3)}};r.flexAnimate=function(t,n,o,u,a){if(p&&r.pagingCount===1)r.direct...
The thing is, if I put FlexSlider in debug mode — that is, use the unminified version of the script — the error doesn't occur.
I've run the minifed version through javascriptlint.com, and it doesn't point out anything too bad.
I've gotten a prettified version of the minified script in Sublime Text; its matching-brace-highlighting fails to match several sets of braces, some of which are siblings of each other, but I can't find any syntax errors by sight in their vicinity.
I've deleted whole sections out of the file until the brace matching worked again to try to narrow down where the error is, but there's not just one section or small identifiable combination of sections I can delete (except for the one that constitutes most of the file) that makes it work.
The thing is, even with this error, that script works. It works completely; it just throws an error. But if I turn on my CMS's Javascript aggregation feature as I should, it makes every script after this one fail.
I know a one-off answer of where my syntax error is isn't very helpful to the wider community, but are there any techniques or services or programs I can use to help me narrow down what's actually going wrong here?

Eclipse error constantly pops up while editing Javascript

I am working on relatively small (100-300 lines) Javascript files in Eclipse and periodically it gets really upset about some piece of code and pops up this error every time I place the cursor on that line. The error is:
'Requesting JavaScript AST from Selection' has encountered a problem.
An internal error occured during "Requesting JavaScript AST from selection".
java.lang.NullPointerException
While I am converting this:
if(p){
// enter code here
} else { return false; }
into this:
if(p){
// enter code here
} return false;
the error pops up several times. Each time it stops my typing and requires me to click the okay button. I then type two more characters and the error appears again.
Any ideas how to either prevent the error or disable whatever Javascript AST is?
This is on Eclipse Java EE, Indigo Service Release 2. It is almost a flat install, only two plugins installed and neither are for SVN and have nothing to do with Javascript.
An even better answer (from the bug report linked by Cliff Ribaudo, comment #10 and others):
Turn off Toggle Mark Occurrences (Alt-Shift-O or the paintbrush icon on the toolbar, which handily, will show you your current state).
Thanks Cliff!
Edited:
At first I thought this was just a trick, but it is working so well, I had to post it as an actual answer.
When the error window pops up, don't close it. Just drag it off to the side, focus back on the main window and keep editing.
When the error happens again Eclipse doesn't change the focus back to the error message. Focus stays in the editing window and you can continue to edit the document.
Likely an eclipse bug. See this thread:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359005
There is a patch posted there which you might try.
Ironically, the solution for me was to install another plugin. After I installed VJET, and set up my JavaScript project to be a VJET-enabled project, the issue went away.
just replace the xml in your .project file (which lies in home directory of your eclipse workspace .
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>your Project Name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
I've been getting this error lately. I am writing Groovy scripts. The fix for me was to update the Groovy plugin.
I was getting same error with gc overhead limit exceeded description in details section of error. To take action on it I have added following in configuration and issue resolved.
Xms512m
Xmx2048m
Ref: GC overhead limit exceeded problem
In short, for me it was eclipse memory problem.

JSLint "Stopping" in Visual Studio

I installed JSLint into VS2010. It works great, except that after it gets to line 50 of the file it is checking, it halts with the message JS Lint: Stopping. (37% Scanned).
When I put the same JS into JSFiddle, and use the JSLint tool there...I get a report that spans the entire file. How can I make the JSLint in Visual Studio scan the entire file?
Does it report a validation error on line 50? Perhaps if you could list the content of line 50, somebody may know what feature it does not like.
JSLint unfortunately stops scanning when it comes across a loop with a variable that wasn't defined outside the loop, e.g.
for (var i=0; i < x; i++)
JSLint gets mighty upset if you declare a variable like shown - I think it is to do with the potentially you have not realising that the variable does not have loop scope.
I had a quick play with JSFiddle's JSLint and I could not get it to report anything as an error, so either this doesn't work or it uses an old JSLint, which doesn't include the feature that causes it to stop in Visual Studio. Does it fail when using http://www.jslint.com/?

How to solve error: "undefined is null or not object ie in ext js" in IE?

I think its the cause of trailing comma, or syntax error, variable used without declaration. My js fiel is 1000 lines od code. Since the error is not provding me the line no. Its becoming dfficult to debug. Please help me with debugging techniques for IE. The script works very well with Firefox, Safari.
I'd jslint the file. That will find the issue as well as any others you may have.
You can run it as a command line utility via node.
include this <script type="text/javascript" src="https://getfirebug.com/firebug-lite-debug.js"></script> and <html debug="true"> will give you an firebug console
http://getfirebug.com/firebuglite#Debug
For debugging in IE I would recommend you install DebugBar. This extension is similar to FireBug for Firefox.
If you are developing through Microsoft Visual Studio I remember it will help you find trailing commas by highlighting the following } element with a green curly underline.
If you use the built-in developer tools in IE8 and later, you can step through your code in the browser and determine which line causes the error - starting from the top.
If you are not using any debugging tools in IE, then I will advise you to - just like Johan and bjornd are suggesting.
Happy hunting :)
If you are using eclipse :
configure spket plug-in editor for java script
It will highlight the missing/incomplete syntax (e.g comma/semicolon)
so you don't need to debug for syntax errors
Guys, I finally did it ? I took the strength of all your techniques.
1) I put the code in a single
try{
code
}
and catch(e) {
alert('Final Err: '+ e.description);
}
and kept initial 200 lines uncommented and the rest commented and ran the file
while(EOF) {
if(got an alert of error)
checked for trailing commas & putting missed semicolons till end.
else
adding some more lines later uncommented out of the commented and ran the file.
}
Finally, the page got succesfully loaded !!!
I had this issue using the Extjs RowExpander user extension. The issue only occurred in IE. I was able to fix it by adding a few lines of code at the top of the 'toggleRow' method:
if (!this.view) {
this.bindView();
}
For some reason IE occasionally chokes on references to 'this.view' (likely a timing issue). Running 'bindview()' ensures that 'this.view' resolves appropriately.

Categories

Resources