How to add external JavaScript file to Magento, so it\'s code would be included on every frontend page?
None of the methods above worked for me because the script was not hosted on the same domain as the website and had to be controlled using a config variable.
This was my solution:
/** @var Mage_Core_Model_Layout $layout */
$layout = Mage::getSingleton('core/layout');
/** @var Mage_Core_Block_Text $block */
$block = $layout->createBlock('Mage_Core_Block_Text', $name);
$block->setText('');
/** @var Mage_Page_Block_Html_Head $head */
$head = $layout->getBlock('head');
$head->append($block);
I did this in an observer observing controller_action_layout_generate_blocks_after