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/)?
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
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.
skin/frontend/default/foobar/js or your own custom library under
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.