Alberto
Alberto

Reputation: 1408

Laravel asset vs mix

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

Answers (1)

Douwe de Haan
Douwe de Haan

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

Related Questions