Categories


Archives


Recent Posts


Categories


Javascript Debugging in Magento

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Hard to believe I haven’t mentioned this one before, but if you’re going to be doing javascript development in Magento, you’ll want to look in the following file

js/varien/js.js

and comment out or nullify the following code

if (!("console" in window) || !("firebug" in console))
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

This bit of javascript was used to “catch” calls to console.log in browsers without firebug. Meaning, with it in place you don’t be able to use console.log with Google Chrome, Safari, Opera, or any other non-firefox browser.

Copyright © Alan Storm 1975 – 2017 All Rights Reserved

Originally Posted: 27th June 2012