# Preferred way to exclude pages from including a script

**URL:** https://discourse.roots.io/t/preferred-way-to-exclude-pages-from-including-a-script/26934
**Category:** sage
**Created:** 2024-04-03T16:42:21Z
**Posts:** 2

## Post 1 by @djmtype — 2024-04-03T16:42:21Z

It’s preferred there should only be one entrypoint according to the docs. However, I need to exclude a few specific pages from including a particular script file.

So, should this be set up in the app.js file instead of what I have specified below?

Originally, I had set up bud:

```
app
    .entry('app', ['@scripts/app', '@styles/app'])
    .entry('app-header', ['@scripts/app-header'])
```

And in my setup.php:

```
add_action('wp_enqueue_scripts', function () {
  if ( !is_page('form-1') || !is_page('some-other') ) {
        bundle('app-header')->enqueue();
  }
}, 100);

add_action('wp_enqueue_scripts', function () {
    bundle('app')->enqueue();
}, 100);
```

---

## Post 2 by @ben — 2024-04-03T18:32:42Z

Use dynamic imports. Take a look at these:

- [How to add Javascript the right way in Sage10 - #2 by csorrentino](https://discourse.roots.io/t/how-to-add-javascript-the-right-way-in-sage10/25047/2)
- [https://bud.js.org/learn/modules/js-modules#dynamic-imports](https://bud.js.org/learn/modules/js-modules#dynamic-imports)
