Haven't touch javascript for 3 years. Just got a javascript project and wanted to know any new ways or tools emerged these years to debug javascript? I used alert 3 years ago.
I am using IE
-
Is there a reason you're using only one browser?Nosredna– Nosredna2009年11月15日 23:30:14 +00:00Commented Nov 15, 2009 at 23:30
-
3If you're working on a JS project, I suggest you stop using IE. It's bad in so many ways. Just use Firefox / Chrome / Safari, and test in IE later.Douwe Maan– Douwe Maan2009年11月15日 23:30:29 +00:00Commented Nov 15, 2009 at 23:30
-
If save debugging in IE until after you've written your code, you are more than likely going to waste a decent amount of time debugging and rewriting. My practice is to develop Javascript from a standpoint of continuous integration. Any time you make a major change to your code you should test it completely, so you can fix problems as they come instead of waiting for the bill.Ryan Lynch– Ryan Lynch2009年11月15日 23:49:16 +00:00Commented Nov 15, 2009 at 23:49
-
I agree. IE is a pain enough to support that you really want to know when things break in it.Nosredna– Nosredna2009年11月16日 00:02:32 +00:00Commented Nov 16, 2009 at 0:02
-
Seriously, check out www.quirksmode.org , having a good understanding of cross browser issues saves you time debugging cross browser issues by spending less time creating them.Ryan Lynch– Ryan Lynch2009年11月16日 00:07:03 +00:00Commented Nov 16, 2009 at 0:07
16 Answers 16
Use the Firebug extension for Firefox, or the built-in Web Inspector in any WebKit browser (Chrome or Safari). In IE8, you can use the built-in Developer ToolS.
7 Comments
For IE (which I don't suggest using), the latest version (IE8) includes developer tools.
IE8 developer tools
For Firefox, there's an extension called Firebug that has DOM manipulation, a JS console, and more.
firebug DOM inspector firebug JS debugger
WebKit (used in Safari and Chrome) has a built-in Web Inspector that includes a JS debugger, along with a DOM outline and manipulation tools, and a JS console.
webkit DOM inspector webkit JS debugger webkit network profiler webkit resource info
5 Comments
You really need a crossbrowser toolkit. Here's mine:
- Gecko (Firefox) : Firebug
- Opera : Dragonfly
- WebKit (Safari / Chrome) : Web Inspector
- IE : Microsoft script debugger
EDIT:
IE 8 added some developer tools, but I haven't used them to any great extent.
EDIT:
If you haven't done JS development in a while I recommend saving yourself a lot of time debugging cross browser issues by browsing the compatibility tables on Peter-Paul Koch's excellent quirksmode site.
4 Comments
I think a Visual Studio / IE8 combo is excellent. Beats Firebug for JavaScript debugging, IMO (and you, of course, use a framework like jQuery to handle crossbrowser issues).
Comments
If you need IE7 debugging, use IE8 in compatibility view with developer tools.
Comments
If you use Visual Studio, I highly recommend debugging with IE, despite what others say. When you hit a debugger statement in IE and you have debugging enabled, you'll get a pop-up to start debugging in Visual Studio.
I don't like Firebug anymore, I don't know where it went wrong, but it's become highly unreliable (ignoring debugger statements) and really can't compete with VS as far as debugging is concerned.
Comments
Dreamweaver as I write it and Firebug for more indepth debugging. alert()s are pretty useful too.
4 Comments
alert() can be replaced by console.log() ;-) And Dreamweaver should be sent straight back to hell, imo.As others have pointed out, most javascript debugging tools come as part of a browser because they are tightly integrated with the Javascript engine itself. This is probably a good thing because you will want to debug each browser separately if you run into a browser-specific quirk.
In the Internet Explorer world, you have two options:
- As Ryan Lynch pointed out, the Microsoft Script Debugger is a separate debugging environment that talks with IE. If you have Visual Studio Web Developer Edition, the tool should already be available to you. You can attach directly to IE from within VS.
- Recommended: Use a debugger that runs in the browser. IE8 has Developer Tools built-in (press F12) or download the Web Development Helper for earlier versions. Both provide a good light-weight environment right inside IE. They also help to debug CSS layout and other aspects of a website.
2 Comments
Firebug for FireFox and AJAX Dynatrace for IE http://ajax.dynatrace.com/pages/
1 Comment
I realize I'm answering a question you didn't ask, but have you tried jQuery? It's a javascript library that abstracts a lot of the DOM manipulation stuff for you so you don't have to worry so much about cross-browser compatibility issues. There are other similar libraries out there, but I believe jQuery has the biggest following at the moment. http://jquery.com/
I use Firebug in Firefox every day. In addition to debugging Javascript (and by extension, jQuery or any other js library), it's a great for CSS debugging.
Comments
real programmers use printf() traces for debugging (kidding).
var de =true, bug =console.log||alert||(de=false)
de&&bug( "Enjoy!")
When not in debug mode, just do de=false. Minimal performance penalty
Comments
Aptana is a great dev platform that allows you to debug both FireFox and IE.
Comments
I use Javascript Debugger plugin to debug errors that are not easy to figure out in firebug. You can set up break points and step through problem area to see variable values..etc. It's a very useful tool.
Comments
I use firebug most of the time with the following firebug plugins.
FireRainbow, FireRainbow enables javascript syntax highlighting for Firebug. This is really cool. Saves a lot of time.
FirePHP,FirePHP enables you to log to your Firebug Console using a simple PHP method call.
Widerbug , can leverage wide screens for js debugging/development. Obsolete now as it is supported in Firebug 1.9 right out of the box.
Comments
I argue to use build-in browser debugger for performance reason. Firefox and Chrome one are good enough.
They allow browse DOM, show dynamically generated sources, show network activity, profile JS, etc.
But don't miss printf-approach with:
console.log("this is %o, event is %o, host is %s", this, e, location.host);
and:
console.log("%s", new Error().stack);
Comments
LINE BY LINE JAVASCRIPT DEBUGGING
To get following set of features try any of the below mentioned two methods.
Features:
- Set and Pause at breakpoints.
- Step into
- Step out
- Step over
- Watch values at breakpoints pause
- Toggle breakpoints
- Continue from paused breakpoints
- and many more...
Method 1:
- Google Chrome> Inspect> Sources Tab
- For detailed help
Method 2:
- Mozilla Firefox> Inspect Element(Q)> Debugger Tab
- For detailed help