I am developing a new admin module and needs to customize the magento admin panel. i've created a new theme in default
package of adminhtml
. In the skin
folder (skin/default/mytheme
) i've included my css files and js files. And i've included them via my layout xml file
<?xml version="1.0"?>
<layout>
<default>
<reference name="head">
<action method="addJs"><script>main.js</script></action>
<action method="addJs"><script>bootstrap/bootstrap.min.js</script></action>
<action method="addCss"><stylesheet>css/bootstrap.min.css</stylesheet></action>
</reference>
</default>
</layout>
Although the css files are loaded, the js files returns 404.
`js/` folder
I've found that magento saves most of the js files in the js/
folder in root. On moving my files here, it works perfectly.
Why does magento save js files here?
How can i save my js files in my package and still include in the header?
Best Answer
The
js/
folder in the root is more for supporting libraries than scripts directly relating to your project or extension. Kind of like thelib/
folder in the root for PHP libraries.To include javascript from the skin folder (either frontend or adminhtml) use the following XML snippet
This will include the javascript from the template folder. In my opinion placing your extensions Javascript in the
js/
folder is back practice.