1

You always get people saying never to modify the core magento files (/app/code/core/), but what about the /js/mage/ files? Will this get overwritten when you upgrade magento? Is there an alternative place to create them (e.g. with core in /app/code/local/mage/)?

  • Anything that will be overwritten on an upgrade is core, including stuff in the skins folder. – Fiasco Labs Feb 3 '14 at 17:00
1

Never edit any file that is in the core.
This includes php classes, template classes, and js files.
What you can do is to "somehow" rewrite them.
You can clone any file in a custom folder but still in js folder.
For example js/my_company/.
Then you can edit the layout files of you theme and make them include your file instead of the original one.

<reference name="head">
  <action method="removeItem"><type>js</type><name>original/js/file</name></action>
  <action method="addJs"><name>my_company/filename.js</name></action>
<reference>

If you want to extend a js "class" don not clone the full file.
You can create your own and just add it to the page.
See a very nice explanation from @Fooman on how to manage these kind of js extensions.

  • Hey Marius, thanks for the answer, my confusion comes from the following - the /js/mage folder isn't actually in the 'core' folder (/app/code/core/), so do they still count as core files? This is what I'm trying to do. – eddhall Feb 3 '14 at 12:08
  • 1
    @Edward. It depends what core means to you. For me it means every file that comes with the Magento archive. The templates are also not located in app/code/code but you should not edit any file in app/design/frontend/base/default either. Same goes for any file in the js folder. – Marius Feb 3 '14 at 12:15
  • Hey Marius, Good to know thanks. All I'm trying to do is add one line of text to a js file, would the fooman link be the best way of doing this? – eddhall Feb 10 '14 at 15:44
1

js/mage is a part of the core Magento Javascript library. In Magento there are a few ways where a Javascript file should live. Your custom JS code can live under a skin JS directory eg. skin/frontend/default/foobar/js or your own custom library under js/foobar. This is probably the better way to override the Javascript file you're trying to edit. If you edit the js/mage folder contents yes, it will get overwritten in an upgrade unless you specifically exclude that directory/files - but after that could come the real trouble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.