# Which is the best practice to include external js in custom node?

**URL:** <https://discourse.nodered.org/t/which-is-the-best-practice-to-include-external-js-in-custom-node/11732>\
**Category:** FAQs\
**Created:** [31 May 2019 15:30 UTC](https://discourse.nodered.org/t/which-is-the-best-practice-to-include-external-js-in-custom-node/11732 "2019-05-31T15:30:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbove731](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gbove731/32/8128_2.png) [@gbove731](https://discourse.nodered.org/u/gbove731)\
**Post date:** [31 May 2019 15:30 UTC](https://discourse.nodered.org/t/which-is-the-best-practice-to-include-external-js-in-custom-node/11732/1 "2019-05-31T15:30:50Z")

</div>

Which is the best practice to include external js in custom node?

I would like to use WebWorker and I need to point to an external javascript file.

Is it possible? How?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [31 May 2019 15:50 UTC](https://discourse.nodered.org/t/which-is-the-best-practice-to-include-external-js-in-custom-node/11732/2 "2019-05-31T15:50:55Z")

</div>

Probably the geofence node is the best example so far - see [https://github.com/hardillb/node-red-node-geofence/blob/52c67e9d038dbb1e0dc4247abefbdb5cd9af76a9/geofence.html#L192](https://github.com/hardillb/node-red-node-geofence/blob/52c67e9d038dbb1e0dc4247abefbdb5cd9af76a9/geofence.html#L192)

---

<div class="post-metadata">

**Author:** ![gbove731](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gbove731/32/8128_2.png) [@gbove731](https://discourse.nodered.org/u/gbove731)\
**Post date:** [3 June 2019 07:57 UTC](https://discourse.nodered.org/t/which-is-the-best-practice-to-include-external-js-in-custom-node/11732/3 "2019-06-03T07:57:45Z")

</div>

Thanks a lot.  
I still can't figure how to refer the static js.

If I create a subfolder "static" with my "webworker.js" I receive a 404.

So I have:

mynode/static/webworker.js

I tried:

```auto
var worker = new Worker("mynode/js/webworker.js");

var worker = new Worker("js/webworker.js");

var worker = new Worker("webworker.js");

```

I always receive a 404 not found error.

How to refer it?

---

<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:** [3 June 2019 08:03 UTC](https://discourse.nodered.org/t/which-is-the-best-practice-to-include-external-js-in-custom-node/11732/4 "2019-06-03T08:03:07Z")

</div>

Hi @gbove731

the bit that was missing from Dave's reply was that you also need to add some code in your node's js side to tell the runtime to serve those files.

> <https://github.com/hardillb/node-red-node-geofence/blob/52c67e9d038dbb1e0dc4247abefbdb5cd9af76a9/geofence.js#L114>
