Thursday 7 May 2015

Defer parsing of JavaScript in Magento

Copy /app/code/core/Mage/Page/Block/Html/Head.php
to
/app/code/local/Mage/Page/Block/Html/Head.php
Go to line 204 and add an defer in line 205
// static and skin javascripts

 $html .= $this->_prepareStaticAndSkinElements('<script type="text/javascript" defer src="%s"%s></script>' . "\n",
            empty($items['js']) ? array() : $items['js'],
            empty($items['skin_js']) ? array() : $items['skin_js'],
            $shouldMergeJs ? array(Mage::getDesign(), 'getMergedJsUrl') : null
        );