# Is it possible to import an external script in templates?

**URL:** <https://discourse.nodered.org/t/is-it-possible-to-import-an-external-script-in-templates/63684>\
**Category:** General\
**Created:** [9 June 2022 14:45 UTC](https://discourse.nodered.org/t/is-it-possible-to-import-an-external-script-in-templates/63684 "2022-06-09T14:45:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [9 June 2022 14:45 UTC](https://discourse.nodered.org/t/is-it-possible-to-import-an-external-script-in-templates/63684/1 "2022-06-09T14:45:12Z")

</div>

I'm trying to import an external graphic into my node-red project, but without success, because the script I'm trying to import is not loading.

This is my script:

```auto
<!DOCTYPE html>
<html>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<body>

<div id="myPlot" style="width:100%;max-width:700px"></div>

<script>

var status = msg.payload[0].status;

var xArray = [50,60,70,80,90,100,110,120,130,140,150];
var yArray = [7,8,8,9,9,9,10,11,14,14,15];

// Define Data
var data = [{
  x: xArray,
  y: yArray,
  mode:"lines"
}];

// Define Layout
var layout = {
  xaxis: {range: [0, 200], title: "Ping"},
  yaxis: {range: [0.0, 23.59], title: "Hour"},  
  title: "Histórico de Ping"
};

// Display using Plotly
Plotly.newPlot("myPlot", data, layout);
</script>

</body>
</html>

```

Is there a workaround for importing scripts or is it not possible?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [9 June 2022 15:01 UTC](https://discourse.nodered.org/t/is-it-possible-to-import-an-external-script-in-templates/63684/2 "2022-06-09T15:01:54Z")

</div>

A Ui-Template should not have html or head or body tags.

Even if they were required you have the CDN outside of head and body.

Get rid of the html and body tags. Also, it goes without saying, a page that uses a cdn will require internet access on the machine it is being viewed.

The alternative is to host this js file on your node-red server. Search forum and read docs for adding `static` folder

---

<div class="post-metadata">

**Author:** ![HuOliveiraWork](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/huoliveirawork/32/62521_2.png) [@HuOliveiraWork](https://discourse.nodered.org/u/HuOliveiraWork)\
**Post date:** [9 June 2022 15:11 UTC](https://discourse.nodered.org/t/is-it-possible-to-import-an-external-script-in-templates/63684/3 "2022-06-09T15:11:02Z")

</div>

A okay, got it. Thanks again

---

<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:** [23 June 2022 15:11 UTC](https://discourse.nodered.org/t/is-it-possible-to-import-an-external-script-in-templates/63684/4 "2022-06-23T15:11:56Z")

</div>

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