Same name in other branches
  1. 6.0.x advagg_mod/src/Asset/DeferCss.php \Drupal\advagg_mod\Asset\DeferCss::callback()
  2. 8.x-3.x advagg_mod/src/Asset/DeferCss.php \Drupal\advagg_mod\Asset\DeferCss::callback()
  3. 8.x-4.x advagg_mod/src/Asset/DeferCss.php \Drupal\advagg_mod\Asset\DeferCss::callback()

Callback to replace individual stylesheet links.

Parameters

array $matches: Array from matches from preg_replace_callback.

Return value

string Updated html string.

File

advagg_mod/src/Asset/DeferCss.php, line 90

Class

DeferCss
Modify stylesheet links to defer them. May lead to Flash of unstyled content.

Namespace

Drupal\advagg_mod\Asset

Code

protected function callback(array $matches) {
    return "<link rel='preload' {$matches[1]} {$matches[2]} as='style' onload=\"this.rel='stylesheet'\" {$matches[3]}/><noscript>{$matches[0]}</noscript>";
}