how to include css & js in magento?

 <block type="page/html_head" name="head" as="head">



<action method="addItem"><type>skin_js</type><name>js/jquery.flexslider.js</name></action>
                <action method="addItem"><type>skin_js</type><name>js/jquery.flexslider-min.js</name></action>


 <action method="addCss"><stylesheet>css/flexslider.css</stylesheet></action>

</block>

I include this code at page.xml.. but ccs & js is not included to follow this code . please help me..

Solutions

In your app/design/frontend/[package]/[theme]/layout folder, create a local.xml and add the following:

<layout>
<default>
    <reference name="head">
        <action method="addItem"><type>skin_js</type><name>js/jquery.flexslider-min.js</name></action>
        <action method="addCss"><stylesheet>css/flexslider.css</stylesheet></action>
    </reference>
</default>
</layout>

If the file already exists, add the contents of <layout> (and if <default> already exists you can add the content of that) to the file.

You don't need to add the flexslider and the minified version (the -min.js file), just the minified is fine.

Tags: Magento 1.x

Similar questions

I have a css file in vendor/module/view/frontend/web/css/style.css in my own module but it is not working
I have a css file in web/css/style.css in my own module . but it is not working . i have called it in my vendor/module/view/frontend/layout/xmlfile . Note : I don't want to add it in theme css i want to add it in my own module .
magento 2 module's css and js files include
I have created a basic plugin in magento 2 and also included .css file in correct place as I have seen in many tutorials but when I open frontend page of magento 2(luma page) and do page inspect and in the console after open the issue in tab , it shows :- Unable to resolve the source file for 'frontend/Magento/luma/en_US/Excellence_Hello/css/style....
Magento 1.9 sendTransactional() doesn't include CSS from email template
I'm using sendTransactional() to send emails programmatically. All working fine besides the following line in the email template is not included Any fixes?
how to include css file to templates (.phtml file )in magento 2?
I wanted to place the contents of style tag in a seperate folder and wanted to include it into this customtext.phtml file. How can I do this?
Magento 2: Include static resources (JavaScript, CSS, fonts) before </head>
How do i Include static resources (JavaScript, CSS, fonts) before in Magento 2? i follow the docs magento 2 Include static resources (JavaScript, CSS, fonts) i have copied the file from base theme to the extended theme my_extended_theme_dir/Magento_Theme/layout/default_head_blocks.xml and here is the code: but no changes, recreated static files, cl...
Magento 2: CSS include sequence
If we include CSS in layout XML as below, Magento includes it after style-l.css and style-m.css. But if we include CSS as below then Magento includes it before style-l.css and style-m.css. So what is the reason for the same ?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.