YUI Logger Bookmarklet

So you’re using YUI Logger in your webapp, and loving it. One problem: how do you hide the console for production, but show it in development? You can have separate build targets, but what if you want to deploy the same package in all your environments?

One option is to use this bookmarklet to load YUI Logger. In other words, just load your page, then run the bookmarklet to load the logger.

One of the upsides of that bookmarklet is that it uses YUI Loader to load the logger code dynamically, so that you don’t have to include the logger code in your production side. The bookmarklet doesn’t work if you don’t have YUI Loader included on your page. For me, though, this was a problem. I don’t use YUI Loader – instead, I combine all my JavaScript library code into a single JS file that’s downloaded once, so that can be cached. And when I looked at the YUI Loader code, it’s actually larger than the YUI Logger code!

So, as an alternative, here’s a bookmarklet that will start a YUI Logger console, assuming you already have the logger code loaded into your page. Bookmark it, or drag it to your toolbar or bookmarks folder.


Note: as far as I can tell, your log statements are recorded even before the console is displayed, so if you have code that executes on page load, its log statements will still appear in the console when you use the bookmarklet after page load.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: