You are here

public function DeferJs::__construct in Advanced CSS/JS Aggregation 8.3

Same name and namespace in other branches
  1. 8.4 advagg_mod/src/Asset/DeferJs.php \Drupal\advagg_mod\Asset\DeferJs::__construct()

DeferCss constructor.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The Drupal module handler.

File

advagg_mod/src/Asset/DeferJs.php, line 50

Class

DeferJs
Add defer tag to scripts.

Namespace

Drupal\advagg_mod\Asset

Code

public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) {
  $this->deferType = $config_factory
    ->get('advagg_mod.settings')
    ->get('css_defer_js_code');
  $this->counter = $config_factory
    ->get('advagg.settings')
    ->get('global_counter');
  $this->moduleHandler = $module_handler;
  $this->skipList = [];

  // Admin Toolbar 8x fails when deferred.
  if ($this->moduleHandler
    ->moduleExists('admin_toolbar')) {
    $this->skipList[] = Crypt::hashBase64(drupal_get_path('module', 'admin_toolbar') . '/js/admin_toolbar.js' . $this->counter);
  }
}