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