Как добавить атрибут defer или async в wp_add_inline_script?
Однако, когда я передаю wp_script_add_data, он ничего не добавляет в скрипт.

Вот как выглядит код:
Код: Выделить всё
// Register/Enqueue the script source if it is configured
if (array_key_exists('path', $s)) {
// Replace constant tags with real constants
$s['path'] = self::localize($s['path'], $s['localize']);
$src = self::scriptArgs($s['handle'], $s['path'], $s['in_footer']);
wp_register_script(...$src);
wp_enqueue_script(...$src);
// // If set add async to script
if ($s['async'] === true) {
$t = $s['handle'];
$t .= '-inline';
// var_dump($src);
wp_script_add_data('rollbar' , 'async/defer', true );
}
// Add inline script to source script if it exists
if (array_key_exists('inline', $s)) {
$s['inline']['contents'] = self::getFileContents($s['inline']['path'], $s['localize']);
wp_add_inline_script($s['handle'], $s['inline']['contents'], $s['inline']['position']);
}
}
когда я добавляю «условно», «lt IE 9», это работает:

Подробнее здесь: https://stackoverflow.com/questions/649 ... sync-defer
Мобильная версия