Question

Wondering how can I link with blade syntax to my jquery/javascript files?

 <script src="../../public/js/jquery.min.js"></script>


 <script src="../../public/js/bootstrap.js"></script>

This didn't work:

 <link type="text/css" rel="stylesheet" href="{{ URL::to('js/jquery.min.js') }}"> 

 <link type="text/css" rel="stylesheet" href="{{ URL::to('js/bootstrap.js') }}">
Was it helpful?

Solution

URL::to($param) directs to your root folder (/public) and adds the string folders. URL::to('js/bootstrap.js') directs to /public/js/bootstrap.js. this looks correct to me.

although you used a css linking tag for javascript. try using:

<script src="{{ URL::to('js/jquery.min.js') }}"></script>
<script src="{{ URL::to('js/bootstrap.js') }}"></script>

OTHER TIPS

You should use the following:

<script src="{{ URL::asset('/js/jquery.min.js') }}"><script/>
<script src="{{ URL::asset('/js/bootstrap.js') }}"><script/>

This will always work. If you are creating a package in workbench this is also the way to go.

And if you want to publish your assets to public you will do:

php artisan asset:publish --bench="vendor/package"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top