cancel
Showing results for 
Search instead for 
Did you mean: 

Is it ok to write JavaScript and CSS code in CMS pages?

Is it ok to write JavaScript and CSS code in CMS pages?

I often write CSS and sometimes JavaScript Code directly in CMS Pages for some minor changes and style fixes, otherwise I always would need to write the code directly into script files and push it via git and such...

 

Is this an accepted way to use magento?

1 REPLY 1

Re: Is it ok to write JavaScript and CSS code in CMS pages?

Instade of writting directly on page, you can do this things.

1. Open that CMS Page.
2. Open the "Design" tab from sidebar.
3. There are you get options like "Layout Update XML"
4. Into this field you are able to add Css and Js file for specific CMS Page only.

<reference name="head">
  <action method="addItem"><type>skin_js</type><name>js/your_foldername/your_js_name.js</name></action> 
  <action method="addItem"><type>skin_css</type><name>css/your_foldername/your_css_name.css</name><params/></action>
</reference>

 
And you need to write yiour code into your Css/Js file.

Was my answer helpful? You can Click Kudos/Accept As Solution.
200+ professional extensions for M1 & M2 with free lifetime updates!