0

I added <script type="text/javascript" src="js/app.js"></script> in Blade file. But I am not getting output when I am browsing. I used php artisan view:clear and php artisan optimize:clear command. But the output is as like before.

I added <div id="app"><prayer_time></prayer_time></div>. This is working fine.

How can I solve the issue ?

1
  • 1
    Is your script part outside of the @section part in the blade file? Commented Nov 20, 2022 at 13:40

1 Answer 1

1

You are most probably putting the script part outside of the @section block in your template, which in turn does not render anything.

If you only need the script on that particular page, I would suggest using the @push method, like this in your template file:

@push('scripts')
    <script type="text/javascript" src="js/app.js"></script>
@endpush

Here you can read more about the @push functionality.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks @brance I tried both. I placed <script type="text/javascript" src="js/app.js"></script> inside @section and I used your way. But none of them is working. Thanks.
Please edit your question and post the blade php code. Did you also clear the view cache?
In order to use @push('scripts') you need to have @stack('scripts') in your layout blade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.