Same name in other branches
  1. 5.0.x advagg_mod/src/EventSubscriber/InitSubscriber.php \Drupal\advagg_mod\EventSubscriber\InitSubscriber::deferCss()
  2. 6.0.x advagg_mod/src/EventSubscriber/InitSubscriber.php \Drupal\advagg_mod\EventSubscriber\InitSubscriber::deferCss()
  3. 8.x-3.x advagg_mod/src/EventSubscriber/InitSubscriber.php \Drupal\advagg_mod\EventSubscriber\InitSubscriber::deferCss()

Apply CSS defer actions.

Parameters

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

File

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

Class

InitSubscriber
Perform initialization tasks for advagg_mod.

Namespace

Drupal\advagg_mod\EventSubscriber

Code

public function deferCss(FilterResponseEvent $response) {
    // Skip if not enabled.
    if (!advagg_mod_css_defer_active()) {
        return;
    }
    $response = $response->getResponse();
    // Only process Html Responses.
    if (!$response instanceof HtmlResponse) {
        return;
    }
    $content = $this->cssDeferer
        ->defer($response->getContent());
    $response->setContent($content);
}