Thursday, June 21st, 2007

DP_Debug: JavaScript Debugging Extensions

Category: JavaScript, Library

Jim Davis has released a simple little JavaScript dumping library, DP_Debug, that supports circular and recursive references, most system objects and specifies certain otherwise ambiguous conditions. It allows for depth of recursion control, labeling and interactive collapse/expand of results. It’s based in essence on the ColdFusion CFDUMP.

In addition the library allows for simple access to Query String and Cookie values and provides basic logging, code timing support and program integration support (the ability to enable or disable debugging). There’s also built in quick reference documentation.

  • dump(): Converts JavaScript objects (their properties, values and relationships) to an HTML representation and displays this in the console for review. It supports objects with circular/recursive references. It’s similar to the insanely useful CFDUMP tag in ColdFusion.
  • dumpCookies(): A convenience method which dumps all available browser cookies to the console.
  • dumpQueryString(): A convenience method which dumps all available query-string names and values to the console.
  • logger(): A method for logging messages to the console using either custom or predefined types. logInfo(), logWarning() and logError() are all shortcut methods for logging specific types of messages easily.
  • timer(): A method for timing blocks of code.
  • getType(): Provides more advanced Object type-recognition than the native “typeof” operator.

Posted by Dion Almaer at 12:04 pm
8 Comments

+++--
3.6 rating from 22 votes

8 Comments »

Comments feed TrackBack URI

As a ColdFusion developer, I have to say that having a like functionality in Javascript is a beautiful thing.

Comment by Jon Hartmann — June 21, 2007

Firebug still rules 8)

Comment by jjjjj — June 21, 2007

Why would someone want to use this instead of Firebug?

Comment by Alex — June 21, 2007

what could be great is to have this extra added functionality integrated into firebug… we don’t need another logger or another timer, yet it’s great to be able to dump objects in a cleaner way than firebug does.

Comment by gonchuki — June 21, 2007

Why would someone want to use this instead of Firebug?

Because some of us test in browsers besides Firefox?

Comment by Trevor — June 21, 2007

Full disclosure: I’m the author of the component. To answer the “Firebug” comments:

a) The component isn’t actually new – it’s almost two years old. I think it actually came out originally about the same time as FireBug.

b) The component is pure JS – not a browser add-in. It doesn’t require an install and can be embedded in the app such that debugging can be enabled interactively from any supported browser.

c) The component works in IE 6+, FireFox 1+ and Opera 9+ (and probably others). FireBug doesn’t.

I love FireBug – this isn’t a replacement by any means. It really does serve a different function.

Comment by Jim Davis — June 21, 2007

Just for completeness:

c) The component works in IE 6+, FireFox 1+ and Opera 9+ (and probably others). FireBug doesn’t.

Have a look at: http://getfirebug.com/lite.html

But this doesn’t mean that you lib isn’t useless, so keep on working.

Comment by Jens — June 22, 2007

Damn, should be (to fast this morning):
But this doesn’t mean that you lib is useless, so keep on working.
Everyone should decide for her-/himself which tool to use.

Comment by Jens — June 22, 2007

Leave a comment

You must be logged in to post a comment.