This blog post covers the different methods you can use to include a Javascript file into Magento. Follow any one of the methods given below:
<reference name="head"> <action method="addJs"><script>folder/file.js</script></action> </reference>
protected function _prepareLayout() { $this->getLayout()->getBlock('head')->addJs('path/from/js/folder/to/your/file.js'); return parent::_prepareLayout(); }
<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>
<action method="addJs"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </action>
Use any one of the above ways to include external JavaScript file in Magento. If you face any sort of difficulties in doing so, then request a quote. Further, our Magento team of developers will assist you in adding the file into your Magento website.