How To Install JQuery In Laravel Vite

Hello Geek, here are the steps on how to install JQuery in Laravel Vite:

  1. Open a terminal window and navigate to the root directory of your Laravel project.
  2. Run the following command to install JQuery:

Code snippet

npm install jquery
  1. Import JQuery in your bootstrap.js file:

Code snippet

import $ from 'jquery';
window.$ = $;
  1. Load your bootstrap.js file using the @vite Blade directive:

Code snippet

@vite(['resources/js/bootstrap.js'])
  1. Now you can use JQuery in your Laravel application.

Here are some additional notes:

  • You can also import JQuery in your app.js file.
  • If you are using a Laravel Mix configuration file, you can add JQuery to the dependencies section.
  • You can also use a CDN to load JQuery.

All the best nerd!

Leave a Reply