Laravel Blade Stacks

One thing that I often forget about is a nice feature in Laravel that allows you to push scripts or other blocks of code into another part of your templates, so for example:

@push('scripts')
    <script src="/example.js"></script>
@endpush

You can do this multiple times and each one will be pushed on to the stack, when you’re ready to dump and display them, you can dump to view using @stack:

<head>
    <!-- Head Contents -->
@stack('scripts')

</head>

Nothing ground breaking here, but incredibly useful. You can read more about it on the Laravel documentation.