# Javascript assets in a theme component

**URL:** <https://meta.discourse.org/t/javascript-assets-in-a-theme-component/189109>\
**Category:** Development\
**Created:** [May 4, 2021, 8:19am UTC](https://meta.discourse.org/t/javascript-assets-in-a-theme-component/189109 "2021-05-04T08:19:44Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Hubbe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hubbe/32/212629_2.png) [@Hubbe](https://meta.discourse.org/u/Hubbe)\
**Post date:** [May 4, 2021, 8:19am UTC](https://meta.discourse.org/t/javascript-assets-in-a-theme-component/189109/1 "2021-05-04T08:19:44Z")

</div>

I’m trying to build an STL preview theme component. There is [an excellent javascript library](https://www.viewstl.com/plugin/) for this, but I’m not sure how to make it work in a theme component.

It’s regular javascript, not es6, which I think means I can’t just stick it in the “javascripts” directory and import it, right? Besides, the library seem to rely on being imported from a script tag.

So I can create a script tag and add it to the document head, but how do I find the name of the library js file? Also, the library is made up of several JS files, and it assumes that those files will be available in the same directory. It goes on to create additional script tags to load the rest of the library.

So, should these files go in the javascripts directory? Or should they be treated as assets? The closest thing I can find to doing something similar is the discourse-math plugin, but if possible I would prefer to keep this as a theme component..

---

_[View the full topic](https://meta.discourse.org/t/javascript-assets-in-a-theme-component/189109)._
