What is the best way to store folder-level javascript functions?
Copy link to clipboard
Copied
I get anxiety worrying about how I should store my javascript functions.
- Should I put all the functions in Config.js?
- Should I put (non-menu related) functions in one file like Functions.js?
- Should each function go in its own separate file Function_01.js, Function_02.js, etc..
What is your experience? Is one way better than the others?
Copy link to clipboard
Copied
I would not add to an existing file like config.js (if it exists). I would organise my startup script files by function, so two entirely different jobs might have different .js files. Very different approach for a 10 line script versus a 10,000 line script. But all this is personal preferences.
Copy link to clipboard
Copied
Thank you!
Copy link to clipboard
Copied
1. NO. This is an internal file that should not be edited.
2. If you'd like.
3. There's no need to do that. I would separate them by project, with maybe one file for general utilities, if you want to use them across projects.
And there's no reason to get anxious about it. Just play around with it and find the best solution for you.
Copy link to clipboard
Copied
Thanks! But why should I not edit Config.js? I am already putting my app.addMenuItem() calls in there to customize the menu.
Copy link to clipboard
Copied
Editing system files is never a good idea, for any application. For starters, you might be interrupting some internal function you're not aware of. Plus, your code is likely to get overwritten if the application updates and re-installs this file. There's really no reason or need to do that. Just use your own files.
Copy link to clipboard
Copied
Thank you! I will use MyConfig.js file instead.

