More than 800+ satisfied clients and counting, since 2010

Blog

Add External JavaScript File in Magento

Add External JavaScript File in Magento Magento eCommerce content management system has a unique blend of advanced and user friendly features. This feature makes it one of the best CMSs for designing and developing online stores. You can even add external JavaScript file in Magento for enhancing functionality of the shopping portal.

How to Add External JavaScript File in Magento

This blog post on how to add external JavaScript file in Magento covers the different methods you can use for this purpose. Follow any one of the methods given below:

  1. The first step to add external JavaScript file in Magento is place it inside the js folder.
  2. Then include it in the XML layout with:

<reference name=”head”>
<action method=”addJs”><script>folder/file.js</script></action>
</reference>

Alternate Methods to add external JavaScript file in Magento

protected function _prepareLayout()
{   $this->getLayout()->getBlock(‘head’)->addJs(‘path/from/js/folder/to/your/file.js’);
return parent::_prepareLayout();  }

Add External JavaScript File in Magento using Blocks

<reference name=”head”><block type=”core/text” name=”google.cdn.jquery”>
<action method=”setText”><text><![CDATA[<script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script><script type=”text/javascript”>jQuery.noConflict();</script>]]></text></action></block></reference>

Add External JavaScript File in Magento using Methods

<action method=”addJs”><script>http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js</script></action>

Use any one of the above ways to add external JavaScript file in Magento. If you face any sort of difficulties in doing so, then request a quote. Our Magento team of developers will assist you in adding the file into your Magento website.

Written by

The author didnt add any Information to his profile yet