# Unable to use \<script\> with plugin outlets

**URL:** https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637
**Category:** Development
**Created:** [April 6, 2019, 7:10pm UTC](https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637 "2019-04-06T19:10:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![barreeeiroo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barreeeiroo/32/165264_2.png) [@barreeeiroo](https://meta.discourse.org/u/barreeeiroo)
#### Post date: [April 6, 2019, 7:10pm UTC](https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637/1 "2019-04-06T19:10:57Z")

</div>

I am trying to make a theme component to display Carbon Ads in my Discourse forum  
Carbon Ads are called by inserting the following code where they should be loaded:

```plaintext
<script src="//cdn.carbonads.com/carbon.js?serve=CK7DL2Q7&placement=wwwkodulario" id="_carbonads_js" async type="text/javascript"></script>

```

In the Theme Component, after checking the [guide](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648), I came to the conclussion that the easiest way to do so is by using plugin outlets  
However, when I add the following piece of code to `</head>` I get the following error:

> Error: Unclosed element `script` (on line 2).

```plaintext
<script type="text/x-handlebars" data-template-name="/connectors/topic-above-post-stream/foobar">
    <script src="//cdn.carbonads.com/carbon.js?serve=CK7DL2Q7&placement=wwwkodulario" id="_carbonads_js" async type="text/javascript"></script>
</script>

```

I guess it is because I should not be supposed to use a script tag inside another script tag, but how can I fix it? Is there any workaround for this?

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [April 6, 2019, 7:48pm UTC](https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637/2 "2019-04-06T19:48:46Z")

</div>

Have you tried putting the script call in the `</head>` file without the `text/x-handlebars` script tag? I haven’t tried this before, but it’s worth a shot as that imports into the application.

---

<div class="post-metadata">

### Author: ![barreeeiroo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barreeeiroo/32/165264_2.png) [@barreeeiroo](https://meta.discourse.org/u/barreeeiroo)
#### Post date: [April 6, 2019, 8:32pm UTC](https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637/3 "2019-04-06T20:32:27Z")

</div>

Yep, it worked!

But the script is not being executed  
I mean, the JavaScript is not being triggered as the ad is not loading  
Any idea why it’s not working?

---

<div class="post-metadata">

### Author: ![barreeeiroo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barreeeiroo/32/165264_2.png) [@barreeeiroo](https://meta.discourse.org/u/barreeeiroo)
#### Post date: [April 7, 2019, 10:42am UTC](https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637/4 "2019-04-07T10:42:30Z")

</div>

I’ve finally gone for the plugin way, and opened a PR to add Carbon Ads to Discourse-AdPlugin:

[https://github.com/discourse/discourse-adplugin/pull/73](https://github.com/discourse/discourse-adplugin/pull/73)

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [April 9, 2019, 3:56pm UTC](https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637/5 "2019-04-09T15:56:29Z")

</div>

@codinghorror is using Carbon Ads on his blog, so I’m inclined to approve your PR and include it in our official plugin. I’ll review.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [April 15, 2019, 3:56pm UTC](https://meta.discourse.org/t/unable-to-use-script-with-plugin-outlets/113637/6 "2019-04-15T15:56:29Z")

</div>

PR is merged. Thanks @barreeeiroo.
