# Pros and Cons about using "custom" Functions vs the basic set of nodes

**URL:** <https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959>\
**Category:** General\
**Created:** [8 September 2018 00:34 UTC](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959 "2018-09-08T00:34:17Z")\
**Posts on this page:** 6\
**Page:** 2

<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:** [13 September 2018 16:41 UTC](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959/21 "2018-09-13T16:41:23Z")

</div>

Great work, thanks for doing this. Really useful.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 September 2018 17:03 UTC](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959/22 "2018-09-13T17:03:53Z")

</div>

@kazuhitoyokoi - do you have a simple set of steps to create the nodegen fuction blocks? Or do I have to wade thru that info to create them?

---

<div class="post-metadata">

**Author:** ![kazuhitoyokoi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kazuhitoyokoi/32/621_2.png) [@kazuhitoyokoi](https://discourse.nodered.org/u/kazuhitoyokoi)\
**Post date:** [14 September 2018 12:42 UTC](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959/23 "2018-09-14T12:42:38Z")

</div>

[The README.md in node-red-nodegen project](https://github.com/node-red/node-red-nodegen) has simple steps to create nodegen function nodes as follows.

```
## Installation
* sudo npm install -g node-red-nodegen

### Create original node from function node
* On Node-RED flow editor, save function node to library with file name (lower-case.js).
* node-red-nodegen ~/.node-red/lib/function/lower-case.js
* cd node-red-contrib-lower-case
* sudo npm link
* cd ~/.node-red
* npm link node-red-contrib-lower-case
* node-red
-> You can use lower-case node on Node-RED flow editor.

```

You can also create "function node without vm module" using the following steps.

```
## Installation
* git clone https://github.com/kazuhitoyokoi/node-red-nodegen.git
* cd node-red-nodegen
* git checkout master-functionwithoutvm
* npm install

### Create original node from function node
* On Node-RED flow editor, save function node to library with file name (lower-case.js).
* node bin/node-red-nodegen.js ~/.node-red/lib/function/lower-case.js --name lower-case-wovm
* cd node-red-contrib-lower-case-wovm
* sudo npm link
* cd ~/.node-red
* npm link node-red-contrib-lower-case-wovm
* node-red
-> You can use lower-case-wovm node on Node-RED flow editor.

```

In the future, Node-RED flow editor will be able to have nodegen UI. Currently there is the design note about the UI.

> **[node-red/node-red](https://github.com/node-red/node-red/wiki/Design:-Node-Generator)**
>
> A visual tool for wiring the Internet of Things. Contribute to node-red/node-red development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 September 2018 14:20 UTC](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959/24 "2018-09-14T14:20:52Z")

</div>

I've just pushed a fix to git that restores the performance of the Switch node:

| Number of messages | Function Time (ms) | Switch Time (ms) |
| --- | --- | --- |
| 16384 | 1216 | 331 |
| 32768 | 2081 | 600 |
| 65536 | 4125 | 1124 |
| 131072 | 8282 | 2207 |

This fix only applies if the node doesn't try to access context.

I suspect a similar performance regression will have been introduced to the Change node - I'll sort that out next.

---

<div class="post-metadata">

**Author:** ![kazuhitoyokoi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kazuhitoyokoi/32/621_2.png) [@kazuhitoyokoi](https://discourse.nodered.org/u/kazuhitoyokoi)\
**Post date:** [19 September 2018 03:52 UTC](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959/25 "2018-09-19T03:52:10Z")

</div>

Thank you for the optimization. 🙂 I'll use the new version of Node-RED!

---

<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:** [17 April 2025 15:25 UTC](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959/27 "2025-04-17T15:25:12Z")

</div>

Closed on 17 April 2025 15:25 UTC



[Previous page](https://discourse.nodered.org/t/pros-and-cons-about-using-custom-functions-vs-the-basic-set-of-nodes/2959.md?page=1)
