0

I've tried everything :

mix.autoload({
    jquery: ['$', 'window.jQuery', 'jQuery'],
});

I've tried jQuery(document).ready(function($){});

I've tried even :

import $ from 'jquery';
window.jQuery = $;
window.$ = $;

But still get the same console error knowing that I'm using Laravel 5.6 with Laravel Mix

Thank you helping

4
  • Check this link stackoverflow.com/a/40122641/562424 Commented Mar 28, 2018 at 14:36
  • It's not my problem :) Commented Mar 28, 2018 at 14:49
  • @R.Saif $(document).ready(function(){}),(jQuery); Could you try it this way. Commented Mar 28, 2018 at 15:00
  • I'e tried already and the error will chajhe to Uncaught Uncaught ReferenceError: jQuery is not defined Commented Mar 28, 2018 at 15:07

2 Answers 2

15

If you are not using vue , delete everything related to vue from assets/js/app.js .

And delete "defer" from layouts/app.blade.php

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

to

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

This will probably work with jquery.

I don't know when using vue. sorry.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the point about removing the defer from the script tag, never noticed it and it fixed my issue.
0

It's an older question but if anyone else ends up reading this I'll went by answer by @kuro and found that adding defer to my own script

<script type="text/javascript" src="{{ URL::asset('js/path/my_script.js') }}" defer></script>

Like that worked for me.

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.