Compiler-like tool for JavaScript?

O

OccasionalFlyer

I just added about 2000 lines of code to a .js file. When I tried to
load the page that uses it, the page would not render. The previous
page in the app gave the message "Please wait" but I never got past
that. I'm assuming this means I messed up braces or brackets or
something like that but looking at it with just my eyes has not
helped. Is there a tool I can download that will do basic validity
checking of my JavaScript? It contains JQuery, so I need the tool to
not flag the JQuery stuff as an error. Thanks.

Ken
 
C

Captain Paralytic

I just added about 2000 lines of code to a .js file.  When I tried to
load the page that uses it, the page would not render.  The previous
page in the app gave the message "Please wait" but I never got past
that.  I'm assuming this means I messed up braces or brackets or
something like that but looking at it with just my eyes has not
helped.  Is there a tool I can download that will do basic validity
checking of my JavaScript?  It contains JQuery, so I need the tool to
not flag the JQuery stuff as an error.  Thanks.

Ken

There is Firefox (+ firebug, but works even without), there is a good
script tool in the IE8 developers tools, there is http://www.jslint.com/.
 
T

Thomas 'PointedEars' Lahn

OccasionalFlyer said:
I just added about 2000 lines of code to a .js file. When I tried to
load the page that uses it, the page would not render. The previous
page in the app gave the message "Please wait" but I never got past
that. I'm assuming this means I messed up braces or brackets or
something like that but looking at it with just my eyes has not
helped. Is there a tool I can download that will do basic validity
checking of my JavaScript?

Yes, it is called a Web browser. Every Web browser seen to date that
supports scripting provides a feature to display script errors, as (contrary
to common belief) a script engine does include a compiler. The FAQ
<http://jibbering.com/faq/> explains how to show script errors. You should
have read it before you posted.

In addition, several IDEs include an ECMAScript syntax checker. I prefer
JSDT from Eclipse WST. It should be noted, though, that language features
vary among implementations and versions, and it depends on the runtime
environment if a feature is supported or not. It is therefore wise not to
use a language features unguarded in a library (or at all) if said feature
is not interoperable. See also said:
It contains JQuery, so I need the tool to not flag the JQuery stuff as an
error.

Even "JQuery stuff", as junky as it evidently is, needs to comply with
syntax rules in order to run. So you are asking the wrong question, and the
answer to the right question is "No, you should not use it."

You're welcome.


PointedEars
 
J

jeanph01

I just added about 2000 lines of code to a .js file.  When I tried to
load the page that uses it, the page would not render.  The previous
page in the app gave the message "Please wait" but I never got past
that.  I'm assuming this means I messed up braces or brackets or
something like that but looking at it with just my eyes has not
helped.  Is there a tool I can download that will do basic validity
checking of my JavaScript?  It contains JQuery, so I need the tool to
not flag the JQuery stuff as an error.  Thanks.

Ken

Like Captain Paralytic told you, Jslint is a good tool. The netbeans
ide is really good also :
http://www.netbeans.org/kb/61/ide/javascript-editor.html

It will tell you warnings and error in your code. Really usefull.
 
G

Gregor Kofler

OccasionalFlyer meinte:
I just added about 2000 lines of code to a .js file. When I tried to
load the page that uses it, the page would not render. The previous
page in the app gave the message "Please wait" but I never got past
that. I'm assuming this means I messed up braces or brackets or
something like that but looking at it with just my eyes has not
helped.

Interesting conclusion.
Is there a tool I can download that will do basic validity
checking of my JavaScript? It contains JQuery, so I need the tool to
not flag the JQuery stuff as an error.

jQuery *is* an error, but it won't be flagged (inexplicably). Use a
proper IDE, like Eclipse with JSDT.

During runtime Firebug will point out bugs.


Gregor
 
G

Gregor Kofler

jeanph01 meinte:
Like Captain Paralytic told you, Jslint is a good tool.

Im pretty sure JSLint will go bananas over jQuery.

Let's see:

"Problem at line 588 character 13: Too many errors. (13% scanned)."
 
T

Thomas 'PointedEars' Lahn

Gregor said:
OccasionalFlyer meinte:

jQuery *is* an error, but it won't be flagged (inexplicably).
ROTFL

Use a proper IDE, like Eclipse with JSDT.

ACK.


PointedEars
 
D

Dr J R Stockton

In comp.lang.javascript message <79492b96-d6c1-4aa6-b101-eb649bc54360@m7
g2000prd.googlegroups.com>, Wed, 12 Aug 2009 17:03:53, OccasionalFlyer
I just added about 2000 lines of code to a .js file. When I tried to
load the page that uses it, the page would not render. The previous
page in the app gave the message "Please wait" but I never got past
that. I'm assuming this means I messed up braces or brackets or
something like that but looking at it with just my eyes has not
helped. Is there a tool I can download that will do basic validity
checking of my JavaScript? It contains JQuery, so I need the tool to
not flag the JQuery stuff as an error. Thanks.


If you have omitted a closing brace }, then what is left may be
perfectly valid until at the end there is an unclosed opening brace. A
syntax checker cannot locate that fault. But a good browser will be
able to tell you what, if anything, is missing.

If you process your vast script in a COPY of
<URL:http://www.merlyn.demon.co.uk/js-quick.htm>, using the Indt
control, you may well be able to see from the indentation roughly where
the error actually is. N.B. You'll want to have any braces in strings
or comment in matched pairs.

Note that adding that amount of code at once, except if you are certain
that it is a faithful copy of properly tested complete code, is
necessarily folly. Code should be modular and tested modularly.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 
O

optimistx

jeanph01 wrote:
....>
The netbeans
ide is really good also :
http://www.netbeans.org/kb/61/ide/javascript-editor.html

It will tell you warnings and error in your code. Really usefull.

Thanks for the tip. This is something I have been searching a long time. I
tried Eclipse a long time ago, but in my computer that was quite slow.
Has anyone tried netbeans and found a probably faster /better (!)
alternative, mainly for a person with not so good memory and using
javascript only occasionally?
 
J

jeanph01

jeanph01 wrote:

...>
The netbeans



Thanks for the tip. This is something I have been searching a long time. I
tried Eclipse a long time ago, but in my computer that was quite slow.
Has anyone tried netbeans and found a probably faster /better (!)
alternative, mainly for a person with not so good memory and using
javascript only occasionally?

I think 1st Javascript Editor would be a good tool too :
http://www.yaldex.com/JSFactory_Pro.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top