<!-- @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-->
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter