1. Overview
Defer JavaScript Extension for Magento 2 is developed based on the version for Magento 1. Like its initial version, Defer JavaScript Extension for Magento 2 is one of the most powerful factors that help to improve the website’s speed.
This module is very useful in reducing the loading time of a website so that customers can enjoy a better shopping experience on your store, leading to stronger engagement and higher brand loyalty.
2. How Does It Work?
You go to Stores ⇒ Configuration ⇒ BSSCOMMERCE ⇒ Defer JavaScript to start setting up.
2.1. Enable
At the backend, you can easily enable or disable BSS Defer JavaScript module by selecting “Yes” or “No” in the Enable box.
In Defer Iframes: Choose Yes to enable this function, otherwise choose No.
(If your webpage has some embed code of other sites, it means that the browser has to load JavaScript files of these pages along with your site. This thing will cause defer score of your website decrease or the site does not perform fast enough for better customer experience. Therefore, using Defer JavaScript will help you to defer these Iframes effectively by loading Iframes of these embed sites only when your site finishes loading completely.)
2.2. Manage Controllers, Paths and Homepage
If you want some of your pages not to be affected by Defer JavaScript Extension for Magento 2, you can easily exclude it by fulfilling these pages’ information into these excluded boxes:
- Exclude controllers and paths: Click Add Match button and write down your wished paths or controllers that you want to disable Defer JavaScript for Magento 2
- Exclude Homepage: you can disable this module on Homepage faster and more easily by selecting “Yes” in the Exclude Home Page box.
*NOTE: You have to fill in the controllers/ paths that you want to exclude the affection of Defer JavaScript Extension for Magento 2 when selecting Add Match button.
- If you do not fill it up, the system will automatically set all pages in your website affected by our module.
- You can click on the wastebasket symbol on the right side of the box to delete the created box.
If you do not know the controllers/paths to fulfill the Exclude Controllers/ Paths box, but you still want to disable Defer JavaScript function for some pages, you can select “Yes” in the Show Controllers and Paths box.
After selecting “Yes”, you can find information about the Controllers / Paths in the table at the end of the frontend page:
2.3 In Put JavaScript in HTML Body Tag
- Choose Yes to put all deferred JavaScript at the end of HTML body tag.
- Choose No to put all deferred JavaScript at the end of the page.
When you finish changing the configuration, you can click on “Save Config” button to save all of your setting with Defer JavaScript.