Invaluable JavaScript Tools

Posted by Charlie Sat, 19 Aug 2006 20:10:00 GMT

If you write a lot of JavaScript, then you'll find Matthias Miller's website chockfull of useful information. And even better, he's put together two great tools.

The first is JavaScript Lint, a tool that analyzes JavaScript code and reports potential errors. Mozilla's SpiderMonkey JavaScript engine has similar functionality, which you can turn on by typing about:config as the URL and then searching for javascript.options.strict. However, JavaScript Lint detects more types of errors and is configurable. To give it a try, I ran it over the MapBuzz code base and was very impressed by the errors it revealed. I immediately added it to our automated testing processes (i.e., its spawned by a rake task now) and have come to depend on it.

And if that wasn't enough, Matthias has adopted a second tool, called Drip, that detects memory leaks in Internet Explorer's JavaScript engine. Memory leaks occur in IE because it uses COM based reference counting to delete objects. Reference counting is fast, and easy to understand, but does not handle circular object references. As you use your website in IE, Drip keeps track of these circular references. Once you're done, it prints out a report showing you where the memory leaks occurred.

Thanks for the great tools Matthias.

Update1 - A few people have pointed out some negative articles aboout JSLint. I've never used JSLint so I don't have any opinions about it. What I'm talking about above is a totally separate project called JavaScript Lint (confusing, isn't it?). I highly recommend JavaScript Lint, it turned up a number of bugs that I hadn't caught previously. In addition, it is highly configurable so it's easy to turn off certains classes of errors. And for the utmost in flexibility, you can annote your code to tell JavaScript Lint to skip certain sections of it.

Update 2 - A couple of people mentioned FireBug and Venkman as invaluable tools. I couldn't agree more - I posted about Firebug a while back when I first started using it. And Venkman has been an old favorite for years - it was great to see it finally updated to workin Firefox 1.5. Hopefully it will also be quickly updated to work with Firefox 2.0. And if you're debugging Internet Explorer, Visual Studio provides a good JavaScript debugger as does Microsoft's free script debugger package.

Posted in ,  | 6 comments | no trackbacks

Comments

  1. Avatar James said about 6 hours later:

    Do you have a link for Matthias Miller’s website?

  2. Avatar Charlie said about 21 hours later:

    Hi James - Forgot to put it in the article. Its http://outofhanwell.com/blog

  3. Avatar Ben said 1 day later:

    Don’t forget firebug and/or venkman! I couldn’t live without them.

  4. Avatar Charlie said 1 day later:

    Hi Ben - great points and I totally agree.

    I posted about Firebug a while back, but should have mentioned it again.

    And Venkman is invaluable when you really need to see what is going on - I particularly like its ability to stop on errors and exceptions. That makes it a lot easier to figure out certain classes of bugs (for example, errors that occur when a XmlHttpRequest request returns).

  5. Avatar jerry said 2 days later:

    is there a way how to print or save a immage out of java generated graphics? i had some server generated java unable to save it anyway (or extension for firefox). thanks

  6. Avatar Matthias Miller said 2 days later:

    Thanks for the kind words, Charlie. I’m glad to hear these tools help you out!

Trackbacks

Use the following link to trackback from your own site:
http://cfis.savagexi.com/trackbacks?article_id=invaluable-javascript-tools&day=19&month=08&year=2006

(leave url/email »)

   Comment Markup Help Preview comment