# Can i add external script to template node?

**URL:** <https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079>\
**Category:** General\
**Created:** [12 September 2018 12:19 UTC](https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079 "2018-09-12T12:19:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [12 September 2018 12:19 UTC](https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079/1 "2018-09-12T12:19:59Z")

</div>

Hi everyone! as the title suggest, i'm trying (well, i haven't tryed yet, because i don't know how) to add an [external script](https://github.com/lindell/JsBarcode) to the template node, should i put the .js in a special folder of the server?

i'll leave you the code that i'm using. All the data is coming from a SQLite database from a previous node (i won't append that node because i would have to give you the db)

[https://pastebin.com/10yQ5piN](https://pastebin.com/10yQ5piN)

Thanks for reading, very grateful!

---

<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:** [12 September 2018 13:08 UTC](https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079/2 "2018-09-12T13:08:06Z")

</div>

Regular template or ui\_template?

If it is a ui\_template, you could try having a file-in node read the script, stick it in msg.template and pass that to the ui\_template and set the ui\_template 'Template type' to 'Added to site section.

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [12 September 2018 13:12 UTC](https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079/3 "2018-09-12T13:12:38Z")

</div>

it's ui\_template, i'll try that!

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [12 September 2018 13:48 UTC](https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079/4 "2018-09-12T13:48:38Z")

</div>

should it work if i just copy all the "text" of the .js file and paste it on my script?

---

<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:** [12 September 2018 16:20 UTC](https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079/5 "2018-09-12T16:20:26Z")

</div>

Depends on what the script does 😁  
Did you try

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [13 September 2018 11:17 UTC](https://discourse.nodered.org/t/can-i-add-external-script-to-template-node/3079/6 "2018-09-13T11:17:12Z")

</div>

Yes, i tried. I copied all the text from that .js and pasted it on one ui\_dashboard and selected the "add to the head section" option, and it worked just fine. Althought there were some functions that i can't make them to work, i'll investigate a little more.

Thanks!
