Same name in other branches
  1. 5.0.x advagg_mod/src/Asset/AsyncJs.php \Drupal\advagg_mod\Asset\AsyncJs::async()
  2. 8.x-3.x advagg_mod/src/Asset/AsyncJs.php \Drupal\advagg_mod\Asset\AsyncJs::async()
  3. 8.x-4.x advagg_mod/src/Asset/AsyncJs.php \Drupal\advagg_mod\Asset\AsyncJs::async()

Add Async attribute to all external script tags.

Parameters

string $content: The response content.

Return value

string Updated content.

File

advagg_mod/src/Asset/AsyncJs.php, line 19

Class

AsyncJs
Add async tag to scripts.

Namespace

Drupal\advagg_mod\Asset

Code

public function async($content) {
    $pattern = '/<script src=".*"/';
    return preg_replace_callback($pattern, [
        $this,
        'callback',
    ], $content);
}