External JavaScript File Referencing

Thank you. If I may make another? We all know I am a noobie at programming, and so I probably am missing alot of the nuances of “why” things get done the way they are done. The formbuilder allows for custom injection of JS, and CSS. I imagine ElfSight specifically avoids giving access for injecting custom HTML for security reasons. But that then seems to limit the ability to “call” other files for custom JS storage. My next request would be to have an area where name files you would like to call in for JS. That way you could organize your functions better, compartmentalize and have overall a more “maintainable” JS strategy. I don’t think it would offer any more security risk that is already being tolerated with custom JS options as it is.

But, like I said, I don’t know the nuances of coding as to why some things are done they way they are.

As always, thank you for being such an awesome team.

John

1 Like

Hi @John_Gudgeon :wave:

Thanks for sharing your feedback!

Could you please describe in more detail what you mean under the name files you would like to call in for JS?

Ooops, grammar error.

A place to name files to include in the custom Javascript. Let me see if I can dig up an example. Here you can see an HTML document, and within the head of that document is the declaration that these other 4 files need to be pulled in to complete the total javascript of this particular page. Three of the files are on the local directory, but the first one actually references a whole well-established library of routines on some other part of the internet. For security reasons I imagine ElfSight would want to limit such remote references to possibly a dozen or so libraries that are considered safe. I imagine the developers will know exactly which these are as they probably use them all day long.

1 Like

A post was merged into an existing topic: Custom made classes and/or IDs

Thanks for sharing the details, @John_Gudgeon!

I’ve discussed your use case with the devs and they recommended using this code in the Custom JS section to pull the external JS files:

function addScript(src) {
  const s = document.createElement('script');
  s.src = src;
  document.body.append(s);
}
addScript(FILENAME_1);
addScript(FILENAME_2);
addScript(FILENAME_3);

FILENAME_1,2,3 should be replaced with the links to JS files. Feel free to check it out :slightly_smiling_face:

If you have any further questions or need assistance with creating a custom code, please let us know. We’ll be delighted to help!