We think that JavaScript is a very important part of web developing today. But sometimes we do not think about simple tips that can increase the performance of the JS. In the post we try to overview some common issues of JS and also the simple solution that helps improve the javascript performance of Magento site.

Read also: Improve Magento 2 performance with AWS CloudFront

In modern web development, JavaScript performance is pivotal. High-performance JavaScript is essential for creating fast, responsive, and engaging web applications. As user expectations for seamless and swift interactions grow, optimizing JavaScript becomes crucial in delivering a superior user experience and maintaining a competitive edge in the digital landscape. This focus on JavaScript performance directly impacts user satisfaction, conversion rates, and overall site effectiveness.

JavaScript bundling is an optimization technique you can use to reduce the number of server requests for JavaScript files. It is achieved by merging multiple JavaScript files together into one file to reduce the number of page requests. By default, Magento 2 allows excluding the particular JavaScript files from bundling by specifying the corresponding file in exclude node of the etc/view.xml file for a theme. However, sometimes it’s not enough.

AJAX requests in Magento

AJAX is a great technology that is used to improve user experience and avoid page reloads, but how can you use it in your own Magento modules? Let’s explore…

1) You should either create a controller, for example: Namespace/YourModule/controllers/AjaxController.php or create a new action in an existing controller