Same name and namespace in other branches
  1. 5.0.x advagg_mod/src/EventSubscriber/InitSubscriber.php \Drupal\advagg_mod\EventSubscriber\InitSubscriber::asyncJs() 1 commentaire
  2. 8.x-3.x advagg_mod/src/EventSubscriber/InitSubscriber.php \Drupal\advagg_mod\EventSubscriber\InitSubscriber::asyncJs() 1 commentaire
  3. 8.x-4.x advagg_mod/src/EventSubscriber/InitSubscriber.php \Drupal\advagg_mod\EventSubscriber\InitSubscriber::asyncJs() 1 commentaire

Apply CSS defer actions.

Paramètres

\Symfony\Component\HttpKernel\Event\ResponseEvent $event: The response event object.

Fichier

advagg_mod/src/EventSubscriber/InitSubscriber.php, line 244

Classe

InitSubscriber
Perform initialization tasks for advagg_mod.

Namespace

Drupal\advagg_mod\EventSubscriber

Code

public function asyncJs(ResponseEvent $event) {
    // Skip if not enabled.
    if (!$this->config
        ->get('js_async') || $this->config
        ->get('js_defer')) {
        return;
    }
    $response = $event->getResponse();
    // Only process Html Responses.
    if (!$response instanceof HtmlResponse) {
        return;
    }
    $content = $this->jsAsyncer
        ->async($response->getContent());
    $response->setContent($content);
}