How To Use Jquery In Vue

Vue.js and jQuery are two popular JavaScript libraries used for building web applications. Although they have different focuses and philosophies, sometimes you may find yourself needing to use jQuery with your Vue.js application. In this blog post, we will discuss how to use jQuery in a Vue project and go through a practical example.

Why would you want to use jQuery in Vue?

Vue is designed to be a progressive framework that can be adopted incrementally. The core library focuses on the view layer only, making it easy to integrate with other libraries or existing projects. However, there might be cases when you need to use jQuery, either because of an existing legacy codebase or because you need some functionality provided by a jQuery plugin.

Before we dive into the details, it’s important to mention that using jQuery with Vue is generally discouraged. Vue provides its own methods and directives for DOM manipulation, and mixing these with jQuery can lead to unpredictable results and hard-to-maintain code. That being said, if you really need to use jQuery, here’s how you can do it.

Installing jQuery in your Vue project

To use jQuery in your Vue project, you’ll need to install it first. You can do this by running the following command in your project folder:

npm install jquery –save

Importing jQuery in your Vue component

Once you’ve installed jQuery, you can start using it in your Vue components. To do this, you’ll need to import the library and attach it to the global window object:

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

Now you have access to the $ and jQuery variables and can use them as you would in a regular jQuery-based application.

Practical example: integrating a jQuery plugin with Vue

Let’s say you want to use the Slick Carousel jQuery plugin in your Vue application. First, install the plugin:

npm install slick-carousel –save

Next, import the CSS and JS files for the plugin in your component:

    @import '~slick-carousel/slick/slick.css';
    @import '~slick-carousel/slick/slick-theme.css';

    import $ from 'jquery';
    window.$ = window.jQuery = $;
    import 'slick-carousel';

Create a mounted lifecycle hook and initialize the Slick Carousel plugin inside it:

    export default {
      mounted() {
          dots: true,
          infinite: true,
          speed: 300,
          <a href=""><a href=""><a href=""><a href="">slidesToShow</a></a></a></a>: 1,
          adaptiveHeight: true,

Finally, add the carousel markup to your component template and use the ref attribute to reference it in your JavaScript:

        <div ref="carousel">
          <div><a href="">Slide 1</a></div>
          <div><a href="">Slide 2</a></div>
          <div><a href="">Slide 3</a></div>

Now you have a working Slick Carousel in your Vue application!


While it’s generally not recommended to mix jQuery and Vue, there are cases when you might need to do so. By following the steps in this guide, you can successfully use jQuery and its plugins in your Vue project. Just remember to be cautious and consider whether there’s a more idiomatic Vue way of achieving the same result before resorting to jQuery.