# Adding new JS to theme

**URL:** https://forum.shopware.com/t/adding-new-js-to-theme/52100
**Category:** International (English Only)
**Tags:** general
**Created:** [29. März 2018 um 11:10 UTC](https://forum.shopware.com/t/adding-new-js-to-theme/52100 "2018-03-29T11:10:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vsimovic](https://avatars.discourse-cdn.com/v4/letter/v/96bed5/32.png) [@vsimovic](https://forum.shopware.com/u/vsimovic)
#### Post date: [29. März 2018 um 11:10 UTC](https://forum.shopware.com/t/adding-new-js-to-theme/52100/1 "2018-03-29T11:10:47Z")

</div>

Hello guys,

maybe this is a bit novice question, but can somebody tell me how to check if my JS file is properly included inside the theme?

I’ve created a file, added it to JS folder of my theme, included it inside the Theme.php using this code:

protected $javascript = [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‘src/js/my-file.js’  
];

However, when i load frontend i don’t see it inside the source code. Is that the right way to check if it’s loading or not?

&nbsp;

Thank you

---

<div class="post-metadata">

### Author: ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)
#### Post date: [29. März 2018 um 11:33 UTC](https://forum.shopware.com/t/adding-new-js-to-theme/52100/2 "2018-03-29T11:33:42Z")

</div>

All javascript&nbsp;(and css) is going to be compiled into one js (and css) file. Therefore you won’t see your script as a seperate file in the source code.

Just add a

```
console.log('loaded');

```

to your script, to see in dev tools if it was&nbsp;loaded.

---

<div class="post-metadata">

### Author: ![enerSpace](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/enerspace/32/13552_2.png) [@enerSpace](https://forum.shopware.com/u/enerSpace)
#### Post date: [29. März 2018 um 11:37 UTC](https://forum.shopware.com/t/adding-new-js-to-theme/52100/3 "2018-03-29T11:37:18Z")

</div>

Hi @vsimovic‍,

yes, this is the best way!

Your JavaScript file will be packed in one file along with the other JavaScript files. Later, only one JavaScript file will be loaded.

Example:

```
/web/cache/1522314906_3c66ed1a002a3ceb873d4ad016155baa.js

```

Best regards

![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/bb8958d17f9f7c07e111287f43ec676d699d0799.png)  
enerSpace Webhosting  
Tel.: +49 511 - 219 568 76 | Web:&nbsp;[https://www.enerspace.de](https://www.enerspace.de/)

---

<div class="post-metadata">

### Author: ![vsimovic](https://avatars.discourse-cdn.com/v4/letter/v/96bed5/32.png) [@vsimovic](https://forum.shopware.com/u/vsimovic)
#### Post date: [30. März 2018 um 08:19 UTC](https://forum.shopware.com/t/adding-new-js-to-theme/52100/4 "2018-03-30T08:19:22Z")

</div>

Hi @enerSpace‍ ,

yeah, all JS files are minified, but in that single JS file i can’t find my code, which is quite strange.

Is there a way to add JS code in footer of the website and tell Shopware not to include it into the minify file or to tell him not to include the JS file into the minify process, but to include it regurarly in footer?

&nbsp;

Thanks

---

<div class="post-metadata">

### Author: ![vsimovic](https://avatars.discourse-cdn.com/v4/letter/v/96bed5/32.png) [@vsimovic](https://forum.shopware.com/u/vsimovic)
#### Post date: [30. März 2018 um 09:21 UTC](https://forum.shopware.com/t/adding-new-js-to-theme/52100/5 "2018-03-30T09:21:21Z")

</div>

I’ve solved the issue. For some reason Shopware wasn’t recompiling theme files properly. Strange, but now it works fine, after i turned on „Disable compiler cache“ option.
