Magento - Add skin CSS and Javascript (JS) to head through layout XML

Posted by Damodar Bashyal on November 12, 2012

 

Today I downloaded one free magento banner slider extension/module. First thing I noticed was it was adding css and js on the template (.phtml) directly like this.

<script type="text/javascript" src="<?php echo $this->getJsUrl('bannerslider/banner1.js') ?>"></script>

<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/bannerslider/banner1.css');?>" media="all" />

It should be ok to add js inside the body, but it's recommended to add css on the head section.

More»

QR Code: Magento - Add skin CSS and Javascript (JS) to head through layout XML