# How do I add data attributes to a script using the HTML builder

**URL:** https://meta.discourse.org/t/how-do-i-add-data-attributes-to-a-script-using-the-html-builder/124026
**Category:** Development
**Created:** [July 26, 2019, 8:10am UTC](https://meta.discourse.org/t/how-do-i-add-data-attributes-to-a-script-using-the-html-builder/124026 "2019-07-26T08:10:55Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [July 26, 2019, 9:32am UTC](https://meta.discourse.org/t/how-do-i-add-data-attributes-to-a-script-using-the-html-builder/124026/2 "2019-07-26T09:32:42Z")

</div>

Ah yeah. The only documentation we reference that I can find is [virtual-dom/virtual-hyperscript/README.md at master · Matt-Esch/virtual-dom · GitHub](https://github.com/Matt-Esch/virtual-dom/blob/master/virtual-hyperscript/README.md) and it’s sort of hidden in our codebase as a comment 🙂 Even with that I couldn’t find the answer you are looking for there. In any case, there is a topic here on Meta that does have the solution:

> [@Widget Helper stripping attributes?](https://meta.discourse.org/t/widget-helper-stripping-attributes/68014/2):
>
> [https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/widgets/header.js.es6#L93-L104](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/widgets/header.js.es6#L93-L104) As per above code, I guess it should be like below decorateWidget('header-icons:before', helper =\> { return h('li.header-dropdown-toggle', [ h('a.icon.btn-flat', { 'id': 'my id', 'href': 'http://example.com', 'title': 'my title', 'attributes': { 'aria-label': 'my label', …

So based on the code you provided, it should work if you change it to the following:

```js
h("script", { src: "http://localhost:5000/pass.js", attributes: { "data-space": "123" } }),

```

---

_[View the full topic](https://meta.discourse.org/t/how-do-i-add-data-attributes-to-a-script-using-the-html-builder/124026)._
