public function AsyncJs::async in Advanced CSS/JS Aggregation 8.4
Same name and namespace in other branches
- 8.3 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\AssetCode
public function async($content) {
$pattern = '/<script src=".*"/';
return preg_replace_callback($pattern, [
$this,
'callback',
], $content);
}