# How to add a script tag inside a Laravel Blade template

> Sometimes you may need to add a little bit of javascript inside a Laravel Blade template. The proper way to do that is to use Laravel's @stack directive…

- URL: https://graffino.com/til/how-to-add-a-script-tag-inside-a-laravel-blade-templatea
- Author: Zeno Popovici
- Channel: laravel
- Published: 2022-01-05
- Updated: 2026-11-21

Sometimes you may need to add a little bit of javascript inside a Laravel Blade template. The proper way to do that is to use Laravel's `@stack` directive:

First, you need to add a `@stack` on the parent page or the layout:

```html
<script src="{{ asset('js/app.js') }}"></script>
@stack('other-scripts')
```

Then you need to `@push` the respective script on the page you need it on.

```html
@push('other-scripts')
<script>
  console.log('do something in js')
</script>
@endpush
```
