Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Jul 08, 2022 Jul 08, 2022

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?

TOPICS
Acrobat SDK and JavaScript
633
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2022 Jul 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 12, 2022 Jul 12, 2022
LATEST

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2022 Jul 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2022 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2022 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 12, 2022 Jul 12, 2022

Thank you! I will use MyConfig.js file instead.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines