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.
Hello Magento Friends, In today’s blog, I will explain How to Add Tooltip in Checkout…
MongoDB is a popular NoSQL database that offers flexibility and scalability when handling modern web…
In NodeJS, callbacks empower developers to execute asynchronous operations like reading files, handling requests, and…
Hello Magento Friends, In today’s blog, we will learn How to Show SKU in Order…
The "Buy Now" and "Add to Cart" buttons serve as the primary call-to-action (CTA) elements…
Hello Magento Friends, In Magento 2, the checkout process allows customers to choose multiple shipping…