How to Use jQuery Library in Magento 2?

  • author-img Nidhi Arora
  • 5 years
How to Use jQuery Library in Magento 2-
image_pdfPrintimage_printSave as PDF

Magento 2 comes with a lot of built-in by-default features. Although, there is always a need to include jQuery while creating a Magento 2 theme as it facilitates a dynamic & interactive front-end. Require JS enhances performance by enabling javascript to get loaded in the background similar to Lazy javascript loading.

To add jQuery library in Magento 2, you need to include the jQuery code inside require:

<script type=”text/javascript”>


    require([‘jquery’],function($ ){











It is the most recommended way and the best practice to use jQuery library in Magento 2. Share your feedback & queries and also let us know if you need any assistance along the way.

Free Webinar

Join us for a FREE webinar