Due to an issue with this other script (in product/list.phtml) <script type="text/javascript"> decorateList('category-list', 'none-recursive') </script>
I had to move some JS at the end of my page.
I wasn't able to make what's indicated above work so I find another way to achieve :
I override the Mage/page/Block/Html/Footer.php controller
by recreating it with the same path in app/local folder
.
Here is the full path to be created if not exists :
app/local/Mage/page/Block/Html/Footer.php
In this file, I add functions from Head.php which can be found in the same folder of Magento's core (i.e. Mage/page/Block/Html/Head.php).
Functions you need to make it works are (obviously the full function, here I just indicate the name to remain concise):
public function addItem($type, $name, $params=null, $if=null, $cond=null)
{...}
public function addJs($name, $params = "")
{...}
public function getCssJsHtml()
{...}
protected function &_prepareStaticAndSkinElements($format, array $staticItems, array $skinItems, $mergeCallback = null)
{...}
protected function _separateOtherHtmlHeadElements(&$lines, $itemIf, $itemType, $itemParams, $itemName, $itemThe)
{...}
protected function _prepareOtherHtmlHeadElements($items)
{...}
Then I add to my custom (the one in my theme) page/html/footer.phtml the call for this :
<?php echo $this->getCssJsHtml() ?>
At the end, I can now add JS in my footer by calling it in any layout by
<action method="addJs"><script>yourscript.js</script></action>