Skip to main content
Participating Frequently
July 8, 2022
Question

What is the best way to store folder-level javascript functions?

  • July 8, 2022
  • 2 replies
  • 748 views

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?

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 8, 2022

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.

Trey5EAEAuthor
Participating Frequently
July 11, 2022

Thanks! But why should I not edit Config.js? I am already putting my app.addMenuItem() calls in there to customize the menu.

try67
Community Expert
Community Expert
July 11, 2022

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.

Legend
July 8, 2022

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.

Trey5EAEAuthor
Participating Frequently
July 12, 2022

Thank you!