Including external js in html templates

Is it possible to include a CDJNS-hosted javascript libraries in the html templates?

For example,

<script type="text/javascript" src=""></script>

Of course, it is possible to just include all the code in one file, but that can’t be the preferred solution, right?

I think for cases like this, it’s probably best to modify the static/index.html. This gives you control over where the script should be loaded (in the head, at the end of the body, before the main Prodigy JS and so on). The custom JS you pass in as "javascript" will be appended to the end of the <body> btw when the app loads.

To find the location of your Prodigy package directory, you can use the following command:

python -c "import prodigy; print(prodigy.__file__)"

Alternatively, it would also be possible to add the script tag in JavaScript itself, e.g. document.createElement('script'), set the src attribute and then append the element to the body or head.

Thanks @ines. This works in case the script is online (like in case of CDN) but what can be done to load js file on local system. In that case, it throws 404 error while trying to find it from http://localhost:8080/recipe.js. I imagine it's looking for file in root directory of server but I have tried putting the file in static folder and its parent folder but both didn't work for me.

If it's in the static folder, you should be able to just include it via recipe.js as a relative path. Another alternative is to have a separate local web server (e.g. using http.server) so you can serve any number of files via a local URL and don't have to put them into the Prodigy directory.