Categories: How ToMagento 2

How to Use Built-In jQuery Library in Magento 2

Yes, there are pros and cons of using javascript. One of the Pros, those are important to make a frontend dynamic and interactive. One of the cons, those may slow down the websites. Magento focused on the issue of slow down and came up with the solution of RequireJS library. They have excluded javascript from the page headers and added the ability to use RequireJS.

You might be knowing RequireJS improves performance by allowing javascript to load in the background like Lazy javascript loading.

The RequireJS library loads JavaScript files and modules. You will need to specify library along with the specific RequireJS configurations in layout.xml to make the library available in your Magento store.

If you want to add your custom JS library apart from the query, then you will need to include the JS code inside

require function like, require([ 'jquery', 'jquery/ui'], function($){ //your js code here  });

 

Do let us know if you are still facing any issue by posting comments or share your feedbacks with us.

Click to rate this post!
[Total: 12 Average: 1.8]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

Five Essential Payroll Compliance Tips for eCommerce Startups

Are you setting up a payroll system for your eCommerce startup? Ensuring compliance with myriad…

1 hour ago

Optimizing Laravel Blade: Unlocking Advanced Fetcher Techniques

In the expansive universe of Laravel development, Blade serves as the stellar templating engine, propelling…

2 hours ago

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

2 days ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

5 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

1 week ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

1 week ago