I am trying to get a shopping cart to work and the developers have told me the problem is with the theme and that there is "bad practice" of javascript being added into all the head files.
1. In app/design/frontend/base/default/layout/jmbasetheme.xml line 16, a block is added to head section. We need to set that section to only load on pages which need it thereby removing it from checkout page.
2. In app/design/frontend/default/jm_sporty/template/page/html/head.phtml every line after 53, there is a lot of javascript added there. That one should also be added only to the pages that need it. Moreover, javascript files should never be included like that from the template files directly as that’s considered bad practice when developing with magento.
Could you let me know how i would resolve step 2?
after line 53 is as follows:
Code:
<?php if(!defined('JM_ADD_JQUERY')): ?> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery/jquery.js') ?>"></script> <?php define('JM_ADD_JQUERY', true); ?> <?php endif; ?> <script type="text/javascript"> //ie10 class var doc = document.documentElement; if(navigator.userAgent.indexOf("MSIE 10.0")){ doc.className+=' ie10'; } var Baseurl = '<?php echo str_replace("index.php/","",Mage::getBaseUrl()); ?>'; </script> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jm.script.js') ?>"></script> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery/plugins/iscroll/iscroll.js') ?>"></script> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery.infinitescroll.js') ?>"></script> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery/jquery.noconflict.js') ?>"></script> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/touchmenu.js') ?>"></script> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/wall.js') ?>"></script> <link href='http://fonts.googleapis.com/css?family=Roboto:400,300,500,700,900' rel='stylesheet' type='text/css' /> <!--[if lt IE 9]> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery/plugins/jquery.mediaqueries.js')?>"></script> <![endif]--> <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/off-canvas.js') ?>"></script> <!--<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> <script type="text/javascript">stLight.options({publisher: "be87d52a-d9cd-4453-b4b1-3169c6f28e3d", doNotHash: false, doNotCopy: false, hashAddressBar: true});</script>-->
2 answers
Hi fenix,
The developer might think that’s considered bad practice when developing with magento from his point of view but I think those are needed for the theme to work properly, let me know if those are preventing your shopping cart from working ?
Thank you so much for this AJ joey, really helped to track my issue down!
This question is now closed