DeferJs
This module introduces a custom solution for deferring scripts. It moves script tags from the given HTML to the end of the body. Every script is additionally checked against ignored list configured in the admin panel.
Installation
This module is a part of MageSuite metapackage
composer require "creativestyle/magesuite-gdpr" ^1.0.0
Configuration
bin/magento config:set deferjs/general/active 1
- enable MageSuite custom to defer the solutionbin/magento config:set dev/js/move_script_to_bottom 0
- Magento deferring should be disabled
Admin settings
Setting for deferring scripts can be found in the MageSuite tab:
Stores -> Configuration -> MageSuite -> Defer JS
Settings
Name | Options | Note |
---|---|---|
Enabled | Yes/No | Enabling/Disabling whole module logic |
Exclude Home Page | Yes/No | Home page will be unaffected by defer js |
Exclude Controllers | Add excluded controllers
| Controllers that will be unaffected by defer js. |
Exclude Paths | Add excluded paths | Paths that will be unaffected by defer js. |
Ignore scripts containing strings | Add excluded scripts | Scripts containing defined strings will be ignored. |
Frontend
Scripts are moved to the bottom of the page: