Using console.log() in Magento

Using the JavaScript Console to do basic debugging is very useful. Unfortunately, Magento hijacks the console object, rendering console.log() useless. There are a number of ways to get around this, but I've found this snippet to be particularly successful in restoring the console:

var i = document.createElement('iframe');
i.style.display = 'none';
document.body.appendChild(i);
window.console = i.contentWindow.console;

Leave a Reply