Rohit Kapali
Rohit Kapali

Reputation: 216

JavaScript file does not load properly in Laravel

So, I am trying to load a js file into a page, the file does not load when I use simple HTML <script> tag, for example

<script src="js/laravel.js"></script>

But it loads when I use blade,

{!! Html::script('js/laravel.js') !!}

But the tricky part is, in some pages the simple HTML <script> loads the js file fine but in some it does not work at all.

Upvotes: 0

Views: 2168

Answers (1)

krisanalfa
krisanalfa

Reputation: 6438

To access your asset path, you can use asset function helper:

<script src="{{ asset('js/laravel.js') }}"></script>

Upvotes: 3

Related Questions