It might be preferable for security reasons and modularity to keep all your functions in a single JavaScript module file instead of embedding them in a HTML page. This way you can also use a debugger within the external functions.
It is possible to gather multiple functions in a single JavaScript module file which makes them available in XPath expressions. Optionally a prefix can be specified to avoid conflicts with other function libraries.
The module library can be found at ./lib.js. Visit it!
calling theanswer(): {theanswer()}
calling hello(): {hello('from function')}
calling helloXPath(): {helloXPath('from XPath function')}
The prefix can be used to avoid conflicts with other function libraries.
lib1:theanswer(): {lib1:theanswer()}
lib1:hello(message): {lib1:hello('from function')}
Making an application with multiple pages or nested Fore elements? No worry, you can reuse the same fx-functionlib without overwriting function definitions. If in conflict the XPath engine always uses the first matching function definition.
In the example below 2 function libraries are used. The second also contains theanswer() but that version is ignored. It also contributes now().
Another library is loaded additionally and can be found at ./lib2.js. Visit it!
And the answer is {theanswer()}
{hello('from XPath function')}
{helloXPath('from XPath function')}
{now()}