Standardizing console APIs: Where?

Thaddee Tyl thaddee.tyl at
Wed Feb 27 13:09:24 PST 2013

On Wed, Feb 27, 2013 at 7:55 PM, François REMY
< at> wrote:
>> In browsers, when logging an object, you can actually click on an arrow
>> to browse through all its properties.
>> Serializing the whole thing on every single console.log, when those
>> happen in a loop,
>> would make the debugging experience a nightmare, performance-wise.
> True but we may expect the string representation to be exact while the details are loaded when expanded only.

Immediate string conversion can still be costly (which is why Firefox
and Safari use a cache).
It is a matter of tradeoff.
Paste this in the developer console:

    (a=[], function() { for (var i=0 ; i<100000 ; i++) { a[0]=i;
console.log(a); } })()

When Chrome does console.log in a huge loop (which can happen by
accident), the tab and the whole DevTools are unresponsive.
When Firefox' DevTools does the same, you can interact with the page
(and the rest of the DevTools) quite fine.
(I'm running it in gmail right now, fwiw.)
I tried to make something as fast in Firefox' JSTerm add-on, but it
isn't as resilient.

> The clickable behavior is an extension to the Console API (which is text-only). I agree that this part should not be standardized.

What subset of <> do
you wish to standardize?
How would the standard require to process the following?

   console.log('%cThis is red text on a green background', 'color:red;

Where do we draw the line?
Can the standard compete with Firebug's ad hoc description, if it is
but a subset?

Also, testing this standard is… hard.

> However, IE has a console.clear() function that I find useful, it should probably be standardized.

That, too, is in <>.

> BTW it should be noted that some browsers only enable logging on a page if the console window is open (or was opened at some point in the page lifetime). This is maybe a way to avoid the slow down that more powerful logging tools could cause.

Best effort. That's the spirit.

More information about the es-discuss mailing list