Javascript Utils Library

135 views
Skip to first unread message

George Pegos

unread,
Mar 31, 2026, 7:42:49 PM (7 days ago) Mar 31
to mementodatabase
Hello team,

I am managing multiple libraries and find myself duplicating the same code across various Javascript fields and JS Automations. Is there a way to build a centralized library containing all my common scripts, so I can import/share it across the rest of my libraries?
Let's assume that I have the getDate() function in a utils library and I want to use it in a Javascript field of another library. Is it possible? Do you have another way to do this?

Thanks,
George

David Gilmore

unread,
Mar 31, 2026, 10:42:52 PM (7 days ago) Mar 31
to mementodatabase
There is no good way to do this, unfortunately.

There is a not so good way to do this, but it is a huge security risk. The method uses the "eval()" javascript function.

I have created a "template" library with all of my often used functions and triggers. When I create a new library, I "clone" this template library, then proceed to modify and add to that cloned library. Really cuts down the time taken to create a new functioning library. I also have a library with a bunch of entries containing javascript script, that I can open, copy the script, and then paste the script into the another library.

Bill Crews

unread,
Mar 31, 2026, 11:56:15 PM (7 days ago) Mar 31
to David Gilmore, mementodatabase
I'm no expert and haven't done it, but I thought that, in the script editor, you can specify a JavaScript library that you've put into GitHub, no? Has anyone done this? 


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mementodatabase/c8368127-2cd8-4bbb-8d32-6b582a39ac37n%40googlegroups.com.

Mmm

unread,
Apr 1, 2026, 7:18:59 AM (6 days ago) Apr 1
to mementodatabase
Про функции в полях JS:
среда, 1 апреля 2026 г. в 06:56:15 UTC+3, bill....@gmail.com:

Bill Crews

unread,
Apr 1, 2026, 12:17:50 PM (6 days ago) Apr 1
to Mmm, mementodatabase
Ok, I didn't think we were mainly talking about JavaScript fields, though it works there too. And if you go into Scripts and select Shared, in there you can also select Add JavaScript libraries, wherein you will see not only our traditional moment.min.js, but also a couple of JavaScript libraries located at GitHub that can be selected. You can open each one for particulars. 

You also have the ability to put your own JavaScript libraries out there on GitHub, and if you do, I believe you can include them in the list under Add JavaScript libraries, no? 

Again, I haven't done it myself, but I remember when Vasya introduced this capability. 


Er Mo

unread,
Apr 1, 2026, 1:11:56 PM (6 days ago) Apr 1
to mementodatabase
Hallo
Ja , man kann Code in mehreren Bibliotheken verwenden . Dafür musst du eine Funktion() erstellen , die die Arbeit macht . Die Funktion kann einen Wert zurük geben . Diese Funktion ( Denn Code ) speichers du , entweder auf GidHub oder wie Ich , in einer JS Datei . Diese Datei hinterlegst du im Internet . Wenn Du die Funktion in einer Bibliothek einsetzen willst ,musst du die JS Bibliothek im Editer hinzufügen . Entweder die GidHub Adresse oder die Web Adresse .

Hello

Yes, you can use code in multiple libraries. To do this, you need to create a function (`()`) that performs the work. This function can return a value. You save this function (the code), either on GidHub or, like me, in a JS file. You then upload this file to the internet. If you want to use the function in a library, you need to add the JS library in the editor. Either the GitHub address or the web address.

Ernst

David Gilmore

unread,
Apr 1, 2026, 1:43:38 PM (6 days ago) Apr 1
to mementodatabase
I have not done this, so I could be mistaken.

If the github storage is storing javascript libraries, unfortunately creating a Javascript library is a rather complex task, not for the faint of heart.

If the github storage is just storing script files, then including them would require doing a cut and paste, which is what we are tyring to be avoid. However, cut and paste is pretty much how I do it now.

The javascript language does allow for including scripts from external sources, but that only works on web pages using HTML. Memento is not a web page.

The "eval()" method does act sort of like a compiler "include" statement, and does work (the source is kept in another library, so it is always accesable). I have it setup in a couple of libraries just to see if it would work. It does, but  it is a little awkward, and of course vulnerable. 

David Gilmore

unread,
Apr 1, 2026, 1:48:17 PM (6 days ago) Apr 1
to mementodatabase
For those who are wondering how I use the eval method, here is the Javascript I use to do the "include":

var p = libByName("GlobalScripts").findByKey("ToDoCal List Future");
if (p == null) {
  message("Global Script not found");
  exit();
}
var buff = p.field("Code");
eval(buff);

Mmm

unread,
Apr 1, 2026, 2:00:38 PM (6 days ago) Apr 1
to mementodatabase
Ничего сложного в создании библиотеки JS на Github или другом сервисе нет.
Создается публичный репозитарий.
Все функции, которые нужны, записываются в текстовый файл.
Файл сохраняется с расширением *.js и размещается в репозитарии.
В библиотеке: для поля JS или скрипта выполняется подключение репозитария и выбор файла, который содержит нужную функцию.
В своем репозитарии можете хранить определенное сервисом количество файлов.
Для работы достаточно одного публичного репозитария с одним или множеством файлов.
После подключения репозитария и файла - файл доступен без интернета (сохраняется на устройстве).

среда, 1 апреля 2026 г. в 20:48:17 UTC+3, aa6...@gmail.com:

Mmm

unread,
Apr 1, 2026, 2:45:52 PM (6 days ago) Apr 1
to mementodatabase
>>>  The javascript language does allow for including scripts from external sources, but that only works on web pages using HTML. Memento is not a web page.

Нужно пробовать любые js-библиотеки в работе.

Например, в Memento прекрасно работают js-библиотеки:
- другие...

Для решения своих задач ищите и пробуйте любые подходящие js-библиотеки. 
В большинстве случаев библиотеки будут работоспособны.

среда, 1 апреля 2026 г. в 21:00:38 UTC+3, Mmm:

George Pegos

unread,
Apr 2, 2026, 6:09:34 AM (6 days ago) Apr 2
to mementodatabase
Hello team again,

Thanks a lot for your help.
I have created a JS library in Github and successfully added it to Memento JS field and also to Automations.
Now I'm writing my code again in order to make it easier and less.

Thanks again

Reply all
Reply to author
Forward
0 new messages