Is there another solution instead using $.getScript(..) for once add external client javascript in created node html file?

If I may chip in here.
if your custom library is for the Editor, then you maybe over engineering this.

See my post here.

Just adding a resources folder to your node, will allow Node RED to use any file from this location, and your HTML file can call into this folder, and it will load only once.

just put a normal script file tag at the top of your HTML file and its loaded (and ready to use), whenever your node configuration is used.

the js file here will be loaded as the editor is loaded (not when your configuration is shown)
i.e it loads once

<script src="resources/node-red-contrib-cool-node/emoji-picker-new.js"></script>

The resources folder should be used if your Node HTML requires it's own JS files (or any other resource for that mater, i.e images etc)

You should not need to use RED.httpAdmin to fetch your own resources, the ability is baked into Node RED for you.

https://nodered.org/docs/creating-nodes/resources

1 Like