Reputation: 1408
I don't get to understand the difference between using asset
or mix
Laravel helper when you have to include some js
or css
file.
<script src="{{ mix('/js/app.js') }}"></script>
vs
<script src="{{ asset('/js/app.js') }}"></script>
Both generates a link to public
folder so is there any difference between them? Is it better to use one of them instead of the other? In which context is it better?
Upvotes: 25
Views: 12187
Reputation: 6666
asset
is just a helper to get the correct path to the file you are using as parameter, where mix
also includes a version number, to help prevent caching of assets.
Read this page to understand more about mix.
Upvotes: 34