The "once" directive will only evaluate the stacks once per rendering cycle which will ensure that there won't be code duplicate.
Laravel Once Directive
For javascript/js stacks you can define it like this.
@once @push('js') <script> console.log('hello world'); </script> @endpush @endonce
For styles/CSS stacks it's pretty much the same.
@once @push('css') <style> .card { background-color: pink; } </style> @endpush @endonce
Leave a reply