How to add external JavaScript file to Magento, so it's code would be included on every frontend page?
question from:https://stackoverflow.com/questions/4654822/adding-external-javascript-file-to-magentoHow to add external JavaScript file to Magento, so it's code would be included on every frontend page?
question from:https://stackoverflow.com/questions/4654822/adding-external-javascript-file-to-magentoPut the JS file somewhere into the "js" folder, and in the XML layout you can include it with:
<reference name="head">
<action method="addJs"><script>folder/file.js</script></action>
</reference>
Hope that helps.
Edit: You can also do it in your block:
protected function _prepareLayout()
{
$this->getLayout()->getBlock('head')->addJs('path/from/js/folder/to/your/file.js');
return parent::_prepareLayout();
}