Press "Enter" to skip to content

Push Directive in Laravel

Sharing is caring!

Dumping your scripts using push directives is better alternative than using @include or @section.

Generally we use a scripts.blade.php file and use @include(‘scripts’) to include scripts. This has been the useful trick but it includes scripts that might never be necessary.

There is a better idea in blade directive here. It called push. Just push any html it any stack whenever it is necessary.

Next thing you need to know is that, if you are declaring stack and push in same page, stack needs to be declared at last and push should be declared before them. It seems like flaw but that’s logical.

Everything is awesome.

Be First to Comment

    Leave a Reply

    Your email address will not be published.