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

Add Async attribute to all external script tags.

Paramètres

string $content: The response content.

Return value

string Updated content.

Fichier

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

Classe

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);
}