# Reading from constants.js file from HTML in custom node

**URL:** <https://discourse.nodered.org/t/reading-from-constants-js-file-from-html-in-custom-node/71247>\
**Category:** Developing Nodes\
**Created:** [25 November 2022 14:40 UTC](https://discourse.nodered.org/t/reading-from-constants-js-file-from-html-in-custom-node/71247 "2022-11-25T14:40:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ItsDaveTheWave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/itsdavethewave/32/65618_2.png) [@ItsDaveTheWave](https://discourse.nodered.org/u/ItsDaveTheWave)\
**Post date:** [25 November 2022 14:40 UTC](https://discourse.nodered.org/t/reading-from-constants-js-file-from-html-in-custom-node/71247/1 "2022-11-25T14:40:30Z")

</div>

Hi there, I wanted to do something apparently simple with my custom nodes, create a constants.js file on the same directory(/nodes) where I store all the .html and .js files.  
I wanted to access the constants defined in this file from the HTML file of one of my nodes to do some validation, but haven't been able to do it so far.

Any idea on how I could do this? Thanks in advance

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [25 November 2022 14:46 UTC](https://discourse.nodered.org/t/reading-from-constants-js-file-from-html-in-custom-node/71247/2 "2022-11-25T14:46:28Z")

</div>

Hi @ItsDaveTheWave

In your nodes root folder `node-red-contrib-cool-node`, add a folder `resources`  
you can then call into this folder like so, in your HTML file

`<script src="resources/node-red-contrib-cool-node/constants.js"></script>`

[Loading extra resources in the editor : Node-RED (nodered.org)](https://nodered.org/docs/creating-nodes/resources)

---

<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:** [25 November 2022 17:07 UTC](https://discourse.nodered.org/t/reading-from-constants-js-file-from-html-in-custom-node/71247/3 "2022-11-25T17:07:04Z")

</div>

Just remember that file will be accessible to anyone with admin access to your node-red instance. Not a good idea to put anything secret in it! 🙂

---

<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:** [9 December 2022 17:07 UTC](https://discourse.nodered.org/t/reading-from-constants-js-file-from-html-in-custom-node/71247/4 "2022-12-09T17:07:47Z")

</div>

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