2

I getting an error on the following line

 <script type="text/javascript" src="js/jquery.js"></script>

I think this is because if have not install jquery in my laravel project. For other packages I use npm. How can I install jQuery in laravel and how to set up the script type link correctly to my index page?

4
  • download the script file and put it in your public/js/ folder Commented Jul 29, 2017 at 17:39
  • You can use npm with laravel as well. Which laravel version did you use? Commented Jul 29, 2017 at 17:45
  • From what I understand, Laravel comes preset with jquery already. Commented Jul 29, 2017 at 17:58
  • When laravel comes with jquery already what i excatly i have to enter in my Index PHp to use it? Commented Jul 29, 2017 at 18:43

2 Answers 2

3

If you're using 5.4, you can just run npm run dev and you'll get jQuery in your app.

Another simple way to add jQuery to your app is too use CDN link:

<script src="http://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>

Or download jQuery minified script to the public/js directory and do this:

<script type="text/javascript" src="{{ asset('js/jquery.js') }}"></script>
Sign up to request clarification or add additional context in comments.

Comments

0

Have a look at my detailed answer at How to use jquery-easing in laravel. I have explained how to compile down all your dependencies including jquery easily into one file public/js/app.js using laravel-mix

Comments

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.