在magento中我们在head.phtml中调用css和js的代码是

<?php echo $this->getCssJsHtml() ?>

那么按照magento的规则,我们需要在layout中去加载css和js

在magento如何通过xml加载外部js

通畅我们会引用外部的css和js,比如google的字体,jquery库以及其他的库

 <!-- Add an EXTERNAL stylesheets  -->
	  <action method="addLinkRel"><rel>stylesheet<href>https://fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400,300,700|Open+Sans:300italic,400,300</href></action>
 
         <!--  Add an EXTERNAL javascript  -->
         <action method="addLinkRel"><rel>text/javascript<href>https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js</href></action>

如何加载magento主题下的css,jss

加载magento主题模板下面的css,js

 <!-- Add stylesheets from your local theme directory located in skin/frontend/ -->
          <action method="addCss"><stylesheet>css/styles.css</stylesheet></action>
 
         <!-- Add javascript from your local theme directory located in skin/frontend/ -->
          <action method="addItem">
	          <type>skin_js<name>js/bootstrap.min.js
          </action>

如何加载magento根目录js文件夹下的js文件

<action method="addJs"><script>bootstrap.min.js</script></action>

在magento中删除css和js

在magento中的布局文件xml中删除js

<action method="removeItem">
<type>js</type>
<name>calendar/calendar.js</name>
</action>

如何在phtm文件中删除js

$this->getLayout->getBlock('head')->removeItem('js', 'calendar/calendar.js');