# How to use functions of external javascript

**URL:** <https://discourse.nodered.org/t/how-to-use-functions-of-external-javascript/38193>\
**Category:** General\
**Created:** [29 December 2020 10:23 UTC](https://discourse.nodered.org/t/how-to-use-functions-of-external-javascript/38193 "2020-12-29T10:23:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gschmidt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gschmidt/32/60349_2.png) [@gschmidt](https://discourse.nodered.org/u/gschmidt)\
**Post date:** [29 December 2020 10:23 UTC](https://discourse.nodered.org/t/how-to-use-functions-of-external-javascript/38193/1 "2020-12-29T10:23:34Z")

</div>

I have installed (on the same server as node-red) an npm based JavaScript of the setopbox I use:

> **[basst85/NextRemoteJs](https://github.com/basst85/NextRemoteJs)**
>
> Simple webinterface for the Ziggo Next setopbox. Contribute to basst85/NextRemoteJs development by creating an account on GitHub.

The files are installed in `/home/pi/Ziggo/NextRemoteJs`

How can I include this JavaScript (index.js) and library in my node-red system and use the functions inside the javascript file?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 December 2020 14:08 UTC](https://discourse.nodered.org/t/how-to-use-functions-of-external-javascript/38193/2 "2020-12-29T14:08:22Z")

</div>

Assuming that all of the code in that library runs _client side_, you can use the static folder option. See your settings.js file.

If it is node.js code, you will need to `require` it in settings.js in the globals section - then you can incorporate it in a function node using `global.get`.

---

<div class="post-metadata">

**Author:** ![gschmidt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gschmidt/32/60349_2.png) [@gschmidt](https://discourse.nodered.org/u/gschmidt)\
**Post date:** [30 December 2020 11:48 UTC](https://discourse.nodered.org/t/how-to-use-functions-of-external-javascript/38193/3 "2020-12-30T11:48:45Z")

</div>

I am a newbie, how will I recognize if this is a node.js code?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [30 December 2020 14:13 UTC](https://discourse.nodered.org/t/how-to-use-functions-of-external-javascript/38193/4 "2020-12-30T14:13:34Z")

</div>

The readme tells you everything you need to know. In fact it clearly says that it runs BOTH a server (index.js) and a client (index.html). The server servers up the web page but otherwise doesn't seem to interact. The server also provides MQTT integration.

So the easiest thing to do would be to run it according to the instructions - separate to Node-RED. Then use it to do a few things and monitor your MQTT Broker to see what message topics it is using. Then you can send those topics from Node-RED.

After that, pull apart the code and translate it to Node-RED. It isn't doing anything that you couldn't easily do in Node-RED.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 February 2021 14:13 UTC](https://discourse.nodered.org/t/how-to-use-functions-of-external-javascript/38193/5 "2021-02-28T14:13:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
