anyway to remove not needed css in laravel using blade @yield-push Stack Overflow

PHOTO EMBED

Sat Jun 04 2022 05:40:52 GMT+0000 (Coordinated Universal Time)

Saved by @oday #php

<!-- @yield only use one time from @section

So use @push @stack in you main layout and many @push in multiple views

In your layout.blade.php add @stack('scripts')

And in index.blade.php add-->




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



<!--And in contact.blade.php add-->


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


<!--You can push multiple css or js or content with @push and @stacks

See https://laravel.com/docs/5.8/blade#stacks


In web.php add route name to contact page

Add this to layout.app.php-->


@if(request()->route()->getName() != "contact")
  Load your css here as page not contact
@endif


<!--So if you open contact page the css not loaded as route name is contact-->
content_copyCOPY

https://stackoverflow.com/questions/56144956/anyway-to-remove-not-needed-css-in-laravel-using-blade/56146617#56146617