R.Saif
R.Saif

Reputation: 11

Uncaught ReferenceError: $ is not defined Laravel 5.6

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

Upvotes: 0

Views: 4783

Answers (2)

Sublth
Sublth

Reputation: 1

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.

Upvotes: 0

kuro
kuro

Reputation: 151

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.

Upvotes: 15

Related Questions