# Enqueueing JS files

**URL:** https://discourse.roots.io/t/enqueueing-js-files/29464
**Category:** bud
**Created:** 2025-04-10T06:29:04Z
**Posts:** 6
**Showing post:** 3 of 6

## Post 3 by @xaykogeki — 2025-04-11T07:02:38Z

> [@Liskownik](#):
>
> `\Roots\bundle('sample')->enqueue();`

Thanks for the suggestions. I find it interesting that both code returns different paths for me.

```
use function Roots\bundle;

bundle('sample')->enqueue();
// returns public/scripts/sample.js

wp_enqueue_script('sample.js', asset('sample')->uri(), false, null);
// works and returns public/js/sample.js
```

Also, I am trying to get this to conditionally load only when a block is added, but doesn’t seem to work.

```
if ( ! wp_script_is( 'sample.js', 'enqueued' ) ) {
  ....
}
```

Hmm. Still needs a fair bit of investigation.

---

_[View the full topic](https://discourse.roots.io/t/enqueueing-js-files/29464)._
