DeferJs

https://github.com/magesuite/defer-js

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 solution

  • bin/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

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.
Use Like: {module}_{controller}_{action}

Exclude Paths

Add excluded paths

Paths that will be unaffected by defer js.
Use Like: women/tops-women/hoodies-and-sweatshirts-women.html

Ignore scripts containing strings

Add excluded scripts

Scripts containing defined strings will be ignored.
As an example "GoogleAnalytics" string can be used to leave it's initialization script in HEAD tag.

 

Frontend

Scripts are moved to the bottom of the page: