Adding async tag to scripts in function.php

Add below code in fucntion.php

function add_defer_attribute($tag, $handle) {
// add script handles to the array below
$scripts_to_defer = array(‘my-js-handle’, ‘another-handle’);
foreach($scripts_to_defer as $defer_script) {
return str_replace(‘ src’, ‘ async=”async” src’, $tag);
}
return $tag;
}
add_filter(‘script_loader_tag’, ‘add_defer_attribute’, 10, 2);

Reference :http://matthewhorne.me/defer-async-wordpress-scripts