Earlier, I posted a solution to add custom CSS and JS in Magento 2.
The below post offers the same solution for Magento 1 store owners.
One can use the below code to add custom CSS and JS in Magento store in order to customize a custom theme or a page.
I’d recommend bookmarking this post for the next time you face a crazy client requirement! 😉
Method to add custom CSS and JS in Magento:
Create app/design/frontend/base/default/layout/extension.xml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?xml version="1.0"?> <layout version="0.1.0"> <default> <reference name="head"> <action method="addItem"> <type>js</type> <name>extension.js</name> </action> <action method="addItem"> <type>skin_css</type> <name>extension.css</name> </action> </reference> </default> </layout> |
That’s it.
Any doubts? Mention them in the Comments section below and I’d be happy to help.
Feel free to share the solution with fellow Magento developers via social media.
Thank you.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.